| Total Complexity | 7 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class TypeCheckerFactory |
||
| 8 | { |
||
| 9 | private static array $checkers = []; |
||
| 10 | |||
| 11 | public static function arrayChecker(): \Closure |
||
| 15 | ); |
||
| 16 | } |
||
| 17 | |||
| 18 | public static function booleanChecker(): \Closure |
||
| 19 | { |
||
| 20 | return self::$checkers['boolean'] = self::$checkers['boolean'] ?? \Closure::fromCallable( |
||
| 21 | fn($value) => is_bool($value) |
||
| 22 | ); |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function floatChecker(): \Closure |
||
| 26 | { |
||
| 27 | return self::$checkers['float'] = self::$checkers['float'] ?? \Closure::fromCallable( |
||
| 28 | fn($value) => is_float($value) |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function integerChecker(): \Closure |
||
| 33 | { |
||
| 34 | return self::$checkers['integer'] = self::$checkers['integer'] ?? \Closure::fromCallable( |
||
| 35 | fn($value) => is_int($value) |
||
| 36 | ); |
||
| 37 | } |
||
| 38 | |||
| 39 | public static function objectChecker(): \Closure |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | public static function stringChecker(): \Closure |
||
| 47 | { |
||
| 48 | return self::$checkers['string'] = self::$checkers['string'] ?? \Closure::fromCallable( |
||
| 49 | fn($value) => is_string($value) |
||
| 50 | ); |
||
| 51 | } |
||
| 52 | |||
| 53 | public static function customTypeChecker(string $type): \Closure |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | } |
||
| 60 |