| Total Complexity | 8 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class Consider |
||
| 15 | { |
||
| 16 | public static $methods = [ |
||
| 17 | 'validationChecks' => 'validation', |
||
| 18 | ]; |
||
| 19 | |||
| 20 | private $mode; |
||
| 21 | |||
| 22 | 121 | public static function add($key, $listener) |
|
| 23 | { |
||
| 24 | 121 | self::$methods[$key] = $listener; |
|
| 25 | 121 | } |
|
| 26 | |||
| 27 | 17 | public function __construct($mode) |
|
| 28 | { |
||
| 29 | 17 | $this->mode = $mode; |
|
| 30 | 17 | } |
|
| 31 | |||
| 32 | 17 | public function __call($method, $args) |
|
| 33 | { |
||
| 34 | 17 | return $this->turn(self::$methods[$method], ...$args); |
|
| 35 | } |
||
| 36 | |||
| 37 | 3 | public function allChecks() |
|
| 38 | { |
||
| 39 | 3 | foreach (self::$methods as $method => $type) { |
|
| 40 | 3 | $this->$method(); |
|
| 41 | } |
||
| 42 | 3 | } |
|
| 43 | |||
| 44 | /** |
||
| 45 | * @param $key |
||
| 46 | * @param callable|null $closure |
||
| 47 | */ |
||
| 48 | 17 | private function turn($key, callable $closure = null) |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param $key |
||
| 66 | */ |
||
| 67 | 17 | private function changeMode($key) |
|
| 73 | 17 | } |
|
| 74 | } |
||
| 75 |