Total Complexity | 8 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
20 | class StringCollection implements StringCollectionInterface |
||
21 | { |
||
22 | protected $elements = []; |
||
23 | |||
24 | /** |
||
25 | * StringCollection constructor. |
||
26 | * |
||
27 | * @param string[] $elements |
||
28 | */ |
||
29 | 17 | public function __construct(array $elements = []) |
|
36 | } |
||
37 | 17 | } |
|
38 | |||
39 | /** |
||
40 | * Add an element, duplicates will be ignored |
||
41 | * |
||
42 | * @param string $element |
||
43 | */ |
||
44 | 13 | public function add(string $element): void |
|
48 | } |
||
49 | 13 | } |
|
50 | |||
51 | /** |
||
52 | * Check to see if an element exists in the lists |
||
53 | * |
||
54 | * @param string $element |
||
55 | * @return bool |
||
56 | */ |
||
57 | 11 | public function has(string $element): bool |
|
58 | { |
||
59 | 11 | return in_array($element, $this->elements); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Remove an element from the list |
||
64 | * |
||
65 | * @param string $element |
||
66 | */ |
||
67 | 4 | public function remove(string $element): void |
|
73 | } |
||
74 | 4 | } |
|
76 |