Total Complexity | 8 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class Fields |
||
10 | { |
||
11 | private $fields = []; |
||
12 | |||
13 | 14 | public function __construct(FieldInterface ...$fields) |
|
14 | { |
||
15 | 14 | foreach ($fields as $field) { |
|
16 | 2 | $this->add($field); |
|
17 | } |
||
18 | 14 | } |
|
19 | |||
20 | 10 | public function add(FieldInterface $field): void |
|
21 | { |
||
22 | 10 | $name = strtolower($field->getName()); |
|
23 | 10 | $this->fields[$name] = $field; |
|
24 | 10 | } |
|
25 | |||
26 | 4 | public function get(string $name): ?FieldInterface |
|
34 | } |
||
35 | |||
36 | 10 | public function getAll(): iterable |
|
37 | { |
||
38 | 10 | yield from $this->fields; |
|
39 | 10 | } |
|
40 | |||
41 | 2 | public function getNames(): array |
|
44 | } |
||
45 | |||
46 | 2 | public function remove(string $name): void |
|
49 | 2 | } |
|
50 | } |
||
51 |