Skip to content

Commit 1689ba3

Browse files
committed
formatting
1 parent de04718 commit 1689ba3

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/Illuminate/Support/Stringable.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,40 @@ public function whenContainsAll(array $needles, $callback, $default = null)
791791
return $this->when($this->containsAll($needles), $callback, $default);
792792
}
793793

794+
/**
795+
* Execute the given callback if the string is empty.
796+
*
797+
* @param callable $callback
798+
* @return static
799+
*/
800+
public function whenEmpty($callback)
801+
{
802+
if ($this->isEmpty()) {
803+
$result = $callback($this);
804+
805+
return is_null($result) ? $this : $result;
806+
}
807+
808+
return $this;
809+
}
810+
811+
/**
812+
* Execute the given callback if the string is not empty.
813+
*
814+
* @param callable $callback
815+
* @return static
816+
*/
817+
public function whenNotEmpty($callback)
818+
{
819+
if ($this->isNotEmpty()) {
820+
$result = $callback($this);
821+
822+
return is_null($result) ? $this : $result;
823+
}
824+
825+
return $this;
826+
}
827+
794828
/**
795829
* Execute the given callback if the string ends with a given substring.
796830
*
@@ -854,19 +888,6 @@ public function whenIsUuid($callback, $default = null)
854888
return $this->when($this->isUuid(), $callback, $default);
855889
}
856890

857-
/**
858-
* Execute the given callback if the string matches the given pattern.
859-
*
860-
* @param string $pattern
861-
* @param callable $callback
862-
* @param callable|null $default
863-
* @return static
864-
*/
865-
public function whenTest($pattern, $callback, $default = null)
866-
{
867-
return $this->when($this->test($pattern), $callback, $default);
868-
}
869-
870891
/**
871892
* Execute the given callback if the string starts with a given substring.
872893
*
@@ -881,37 +902,16 @@ public function whenStartsWith($needles, $callback, $default = null)
881902
}
882903

883904
/**
884-
* Execute the given callback if the string is empty.
885-
*
886-
* @param callable $callback
887-
* @return static
888-
*/
889-
public function whenEmpty($callback)
890-
{
891-
if ($this->isEmpty()) {
892-
$result = $callback($this);
893-
894-
return is_null($result) ? $this : $result;
895-
}
896-
897-
return $this;
898-
}
899-
900-
/**
901-
* Execute the given callback if the string is not empty.
905+
* Execute the given callback if the string matches the given pattern.
902906
*
907+
* @param string $pattern
903908
* @param callable $callback
909+
* @param callable|null $default
904910
* @return static
905911
*/
906-
public function whenNotEmpty($callback)
912+
public function whenTest($pattern, $callback, $default = null)
907913
{
908-
if ($this->isNotEmpty()) {
909-
$result = $callback($this);
910-
911-
return is_null($result) ? $this : $result;
912-
}
913-
914-
return $this;
914+
return $this->when($this->test($pattern), $callback, $default);
915915
}
916916

917917
/**

0 commit comments

Comments
 (0)