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