| Total Complexity | 5 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ValuePath extends AbstractNode implements Path |
||
| 11 | { |
||
| 12 | private AttributePath $attributePath; |
||
| 13 | |||
| 14 | private ?string $subAttribute; |
||
| 15 | |||
| 16 | private Node $node; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Value path.. |
||
| 20 | * |
||
| 21 | * @param AttributePath $attributePath |
||
| 22 | * @param Node $node |
||
| 23 | * @param string|null $subAttribute |
||
| 24 | * @param Node|null $parent |
||
| 25 | */ |
||
| 26 | public function __construct( |
||
| 27 | AttributePath $attributePath, |
||
| 28 | Node $node, |
||
| 29 | ?string $subAttribute = null, |
||
| 30 | ?Node $parent = null |
||
| 31 | ) { |
||
| 32 | parent::__construct($parent); |
||
| 33 | |||
| 34 | $this->attributePath = $attributePath; |
||
| 35 | $this->subAttribute = $subAttribute; |
||
| 36 | |||
| 37 | $this->node = $node; |
||
| 38 | $this->node->setParent($this); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Get attribute path. |
||
| 43 | * |
||
| 44 | * @return AttributePath |
||
| 45 | */ |
||
| 46 | public function getAttributePath(): AttributePath |
||
| 47 | { |
||
| 48 | return $this->attributePath; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get sub attribute. |
||
| 53 | * |
||
| 54 | * Paths in PATCH requests can have a value path followed by a sub attribute. |
||
| 55 | * |
||
| 56 | * @return string|null |
||
| 57 | */ |
||
| 58 | public function getSubAttribute(): ?string |
||
| 59 | { |
||
| 60 | return $this->subAttribute; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Return a new ValuePath with sub attribute. |
||
| 65 | * |
||
| 66 | * @param string $subAttribute |
||
| 67 | * |
||
| 68 | * @return ValuePath |
||
| 69 | */ |
||
| 70 | public function withSubAttribute(string $subAttribute): ValuePath |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Get node. |
||
| 80 | * |
||
| 81 | * @return Node |
||
| 82 | */ |
||
| 83 | public function getNode(): Node |
||
| 86 | } |
||
| 87 | } |
||
| 88 |