| Total Complexity | 7 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Coverage | 86.67% |
| Changes | 3 | ||
| 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) |
|
| 22 | 15 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Find field class. |
||
| 26 | * |
||
| 27 | * @param string $method |
||
| 28 | * @return bool|string |
||
| 29 | */ |
||
| 30 | 15 | public function findFieldClass(string $method) |
|
| 31 | { |
||
| 32 | 15 | $fields = $this->config->getFields(); |
|
| 33 | if (isset($fields[$method])) { |
||
| 34 | $class = $fields[$method]; |
||
| 35 | 15 | } |
|
| 36 | 15 | if (isset($class) && class_exists($class)) { |
|
| 37 | 15 | return $class; |
|
| 38 | } |
||
| 39 | 15 | return false; |
|
| 40 | 15 | } |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Generate a Field object and add to form builder if Field exists. |
||
| 44 | * |
||
| 45 | * @param string $method |
||
| 46 | * @param $args |
||
| 47 | * @return FieldInterface |
||
| 48 | * @throws FieldDoesNotExistsException |
||
| 49 | */ |
||
| 50 | public function __call(string $method, array $args): FieldInterface |
||
| 57 | } |
||
| 58 | } |
||
| 59 |