| Total Complexity | 10 |
| Total Lines | 79 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | class Conditions implements ConditionsInterface |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var array |
||
| 9 | */ |
||
| 10 | protected $elements; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @param array $elements |
||
| 14 | */ |
||
| 15 | 15 | public function __construct(array $elements = []) |
|
| 16 | { |
||
| 17 | 15 | $this->setElements($elements); |
|
| 18 | 15 | } |
|
| 19 | |||
| 20 | /** |
||
| 21 | * {@inheritdoc} |
||
| 22 | */ |
||
| 23 | 15 | public function setElements(array $elements): void |
|
| 24 | { |
||
| 25 | 15 | $this->elements = $elements; |
|
| 26 | 15 | } |
|
| 27 | |||
| 28 | /** |
||
| 29 | * {@inheritdoc} |
||
| 30 | */ |
||
| 31 | 2 | public function getElements(): array |
|
| 32 | { |
||
| 33 | 2 | return $this->elements; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | 8 | public function find(string $path, $default = null) |
|
| 40 | { |
||
| 41 | 8 | $element = $this->elements; |
|
| 42 | |||
| 43 | 8 | foreach (\explode(static::FIND_SEPARATOR, $path) as $node) { |
|
| 44 | 8 | if (isset($element[$node])) { |
|
| 45 | 2 | $element = $element[$node]; |
|
| 46 | } else { |
||
| 47 | 8 | return $default; |
|
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | 2 | return $element; |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | 5 | public function offsetExists($offset) |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | 5 | public function offsetGet($offset) |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * {@inheritdoc} |
||
| 72 | */ |
||
| 73 | 5 | public function offsetSet($offset, $value) |
|
| 74 | { |
||
| 75 | 5 | $this->elements[$offset] = $value; |
|
| 76 | 5 | } |
|
| 77 | |||
| 78 | /** |
||
| 79 | * {@inheritdoc} |
||
| 80 | */ |
||
| 81 | 5 | public function offsetUnset($offset) |
|
| 84 | 5 | } |
|
| 85 | } |
||
| 86 |