Total Complexity | 16 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class ArrayItem |
||
8 | { |
||
9 | public ?string $key; |
||
10 | /** @var mixed */ |
||
11 | public $value; |
||
12 | public bool $wrapValue = true; |
||
13 | public bool $wrapKey; |
||
14 | public function __construct(?string $key, $value = null, bool $wrapKey = false) |
||
15 | { |
||
16 | $this->key = $key; |
||
17 | $this->value = $value; |
||
18 | $this->wrapKey = $wrapKey; |
||
19 | } |
||
20 | public function __toString() |
||
21 | { |
||
22 | $result = ''; |
||
23 | if ($this->key !== null) { |
||
24 | $result = $this->wrapKey ? "'{$this->key}' => " : "{$this->key} => "; |
||
25 | } |
||
26 | return $result . $this->renderValue($this->value); |
||
27 | } |
||
28 | private function renderValue($value) |
||
54 | } |
||
55 | } |
||
56 |