| Total Complexity | 10 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class DictionarySet implements ISet |
||
| 13 | { |
||
| 14 | private $data = []; |
||
| 15 | |||
| 16 | protected function computeKey($value) |
||
| 17 | { |
||
| 18 | if (is_int($value)) { |
||
| 19 | return $value; |
||
| 20 | } else { |
||
| 21 | return serialize($value); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | //region ISet |
||
| 26 | |||
| 27 | public function contains($value): bool |
||
| 28 | { |
||
| 29 | $key = $this->computeKey($value); |
||
| 30 | return isset($this->data[$key]); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function add($value): void |
||
| 37 | } |
||
| 38 | |||
| 39 | public function remove($value): void |
||
| 43 | } |
||
| 44 | |||
| 45 | public function clear(): void |
||
| 46 | { |
||
| 47 | $this->data = []; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function toArray(): array |
||
| 53 | } |
||
| 54 | |||
| 55 | public function generateItems(): \Generator |
||
| 56 | { |
||
| 57 | foreach ($this->data as $item) { |
||
| 58 | yield $item; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | //endregion |
||
| 63 | |||
| 64 | //region \Countable |
||
| 65 | |||
| 66 | public function count() |
||
| 69 | } |
||
| 70 | |||
| 71 | //endregion |
||
| 73 |