@@ -19,8 +19,9 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | public static function stringWithLengthBetween(int $minimumLength, int $maximumLength): \Closure |
| 21 | 21 | { |
| 22 | - if ($maximumLength < 0 || $maximumLength < 1) |
|
| 23 | - throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1'); |
|
| 22 | + if ($maximumLength < 0 || $maximumLength < 1) { |
|
| 23 | + throw new \InvalidArgumentException('Minimum length cannot be below 0, maximum length cannot be below 1'); |
|
| 24 | + } |
|
| 24 | 25 | |
| 25 | 26 | return function ($value) use ($minimumLength, $maximumLength) |
| 26 | 27 | { |
@@ -36,8 +37,9 @@ discard block |
||
| 36 | 37 | */ |
| 37 | 38 | public static function intBetween(int $minimum, int $maximum): \Closure |
| 38 | 39 | { |
| 39 | - if ($maximum <= $minimum) |
|
| 40 | - throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 40 | + if ($maximum <= $minimum) { |
|
| 41 | + throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | return function ($value) use ($minimum, $maximum) |
| 43 | 45 | { |
@@ -53,8 +55,9 @@ discard block |
||
| 53 | 55 | */ |
| 54 | 56 | public static function intBetweenExclusive(int $minimum, int $maximum): \Closure |
| 55 | 57 | { |
| 56 | - if ($maximum <= $minimum) |
|
| 57 | - throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 58 | + if ($maximum <= $minimum) { |
|
| 59 | + throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | return function ($value) use ($minimum, $maximum) |
| 60 | 63 | { |
@@ -70,8 +73,9 @@ discard block |
||
| 70 | 73 | */ |
| 71 | 74 | public static function floatBetween(float $minimum, float $maximum): \Closure |
| 72 | 75 | { |
| 73 | - if ($maximum <= $minimum) |
|
| 74 | - throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 76 | + if ($maximum <= $minimum) { |
|
| 77 | + throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 78 | + } |
|
| 75 | 79 | |
| 76 | 80 | return function ($value) use ($minimum, $maximum) |
| 77 | 81 | { |
@@ -87,8 +91,9 @@ discard block |
||
| 87 | 91 | */ |
| 88 | 92 | public static function floatBetweenExclusive(float $minimum, float $maximum): \Closure |
| 89 | 93 | { |
| 90 | - if ($maximum <= $minimum) |
|
| 91 | - throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 94 | + if ($maximum <= $minimum) { |
|
| 95 | + throw new \InvalidArgumentException('Maximum can not be lesser than or equal to minimum.'); |
|
| 96 | + } |
|
| 92 | 97 | |
| 93 | 98 | return function ($value) use ($minimum, $maximum) |
| 94 | 99 | { |
@@ -129,8 +134,9 @@ discard block |
||
| 129 | 134 | */ |
| 130 | 135 | public static function stringOneOf(...$allowedValues): \Closure |
| 131 | 136 | { |
| 132 | - if (!Utils::validateArray(Types::string(), $allowedValues)) |
|
| 133 | - throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only'); |
|
| 137 | + if (!Utils::validateArray(Types::string(), $allowedValues)) { |
|
| 138 | + throw new \InvalidArgumentException('Ranges::stringOneOf expects arguments of type string only'); |
|
| 139 | + } |
|
| 134 | 140 | |
| 135 | 141 | return function ($value) use ($allowedValues) |
| 136 | 142 | { |
@@ -43,8 +43,9 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public static function createReflectionObject(string $class): \ReflectionClass |
| 45 | 45 | { |
| 46 | - if (!class_exists($class)) |
|
| 47 | - throw new \InvalidArgumentException('The given class does not exist'); |
|
| 46 | + if (!class_exists($class)) { |
|
| 47 | + throw new \InvalidArgumentException('The given class does not exist'); |
|
| 48 | + } |
|
| 48 | 49 | |
| 49 | 50 | return new \ReflectionClass($class); |
| 50 | 51 | } |
@@ -57,13 +58,15 @@ discard block |
||
| 57 | 58 | */ |
| 58 | 59 | public static function __callStatic(string $method, array $arguments): \Closure |
| 59 | 60 | { |
| 60 | - if (!method_exists(\ReflectionClass::class, $method)) |
|
| 61 | - throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist'); |
|
| 61 | + if (!method_exists(\ReflectionClass::class, $method)) { |
|
| 62 | + throw new \InvalidArgumentException('Cannot create closure from method ReflectionClass::' . $method . ', it does not exist'); |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | return function ($value) use ($method, $arguments) |
| 64 | 66 | { |
| 65 | - if (!Types::string()($value)) |
|
| 66 | - return false; |
|
| 67 | + if (!Types::string()($value)) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | $reflection = static::createReflectionObject($value); |
| 69 | 72 | |
@@ -60,8 +60,9 @@ discard block |
||
| 60 | 60 | public static function validateArray(\Closure $closure, array $values): bool |
| 61 | 61 | { |
| 62 | 62 | foreach ($values as $value) |
| 63 | - if (!$closure($value)) |
|
| 64 | - return false; |
|
| 63 | + if (!$closure($value)) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 65 | 66 | |
| 66 | 67 | return true; |
| 67 | 68 | } |
@@ -74,8 +75,9 @@ discard block |
||
| 74 | 75 | public static function createClosureFromCallable(callable $callable) |
| 75 | 76 | { |
| 76 | 77 | // Closure::fromCallable was introduced in PHP 7.1.0 |
| 77 | - if (version_compare(PHP_VERSION, '7.1.0', '>=')) |
|
| 78 | - return \Closure::fromCallable($callable); |
|
| 78 | + if (version_compare(PHP_VERSION, '7.1.0', '>=')) { |
|
| 79 | + return \Closure::fromCallable($callable); |
|
| 80 | + } |
|
| 79 | 81 | |
| 80 | 82 | return function ($value) use ($callable) |
| 81 | 83 | { |