| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 81.25% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Field |
||
| 12 | { |
||
| 13 | protected Configuration $config; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Form constructor. |
||
| 17 | * @param Configuration $config |
||
| 18 | */ |
||
| 19 | 15 | public function __construct(Configuration $config) |
|
| 20 | { |
||
| 21 | 15 | $this->config = $config; |
|
| 22 | 15 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Find field class. |
||
| 26 | * |
||
| 27 | * @param string $method |
||
| 28 | * @return bool|mixed |
||
| 29 | */ |
||
| 30 | 15 | public function findFieldClass(string $method) |
|
| 31 | { |
||
| 32 | 15 | if (is_null($method)) { |
|
|
|
|||
| 33 | return false; |
||
| 34 | } |
||
| 35 | 15 | $fields = $this->config->getFields(); |
|
| 36 | 15 | if (isset($fields[$method])) { |
|
| 37 | 15 | $class = $fields[$method]; |
|
| 38 | } |
||
| 39 | 15 | if (isset($class) && class_exists($class)) { |
|
| 40 | 15 | return $class; |
|
| 41 | } |
||
| 42 | return false; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Generate a Field object and add to form builder if Field exists. |
||
| 47 | * |
||
| 48 | * @param string $method |
||
| 49 | * @param $args |
||
| 50 | * @return FieldInterface |
||
| 51 | * @throws FieldDoesNotExistsException |
||
| 52 | */ |
||
| 53 | 15 | public function __call(string $method, array $args): FieldInterface |
|
| 59 | } |
||
| 60 | } |
||
| 61 |