@@ -7,7 +7,7 @@ |
||
| 7 | 7 | /** |
| 8 | 8 | * @param mixed $value |
| 9 | 9 | * @param string $pattern |
| 10 | - * @return bool|array |
|
| 10 | + * @return callable |
|
| 11 | 11 | */ |
| 12 | 12 | private static function parse($value, $pattern) |
| 13 | 13 | { |
@@ -16,17 +16,17 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | $pattern = trim($pattern); |
| 18 | 18 | |
| 19 | - if(is_numeric($pattern) && is_numeric($value)) { |
|
| 19 | + if (is_numeric($pattern) && is_numeric($value)) { |
|
| 20 | 20 | return []; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if(preg_match(self::$booleans, $pattern) === 1 && is_bool($value)) { |
|
| 23 | + if (preg_match(self::$booleans, $pattern) === 1 && is_bool($value)) { |
|
| 24 | 24 | return []; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if(preg_match(self::$strings, $pattern) === 1 && is_string($value)) { |
|
| 27 | + if (preg_match(self::$strings, $pattern) === 1 && is_string($value)) { |
|
| 28 | 28 | $string_pattern = substr($pattern, 1, strlen($pattern) - 2); |
| 29 | - if($string_pattern == $value) { |
|
| 29 | + if ($string_pattern == $value) { |
|
| 30 | 30 | return []; |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -41,10 +41,10 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public static function match($value, array $patterns) |
| 43 | 43 | { |
| 44 | - foreach($patterns as $pattern => $callback) { |
|
| 44 | + foreach ($patterns as $pattern => $callback) { |
|
| 45 | 45 | $match = self::parse($value, $pattern); |
| 46 | 46 | |
| 47 | - if($match !== false) { |
|
| 47 | + if ($match !== false) { |
|
| 48 | 48 | return call_user_func_array($callback, $match); |
| 49 | 49 | } |
| 50 | 50 | } |