1: <?php
2: namespace Pharborist\Objects;
3:
4: use Pharborist\Node;
5: use Pharborist\ParentNode;
6: use Pharborist\TokenNode;
7: use Pharborist\Variables\VariableExpressionNode;
8:
9: 10: 11:
12: class ObjectPropertyNode extends ParentNode implements VariableExpressionNode {
13: 14: 15:
16: protected $object;
17:
18: 19: 20:
21: protected $property;
22:
23: 24: 25:
26: public function getObject() {
27: return $this->object;
28: }
29:
30: 31: 32:
33: public function getProperty() {
34: return $this->property;
35: }
36:
37: 38: 39: 40: 41: 42: 43:
44: public function getPropertyName() {
45: $root_property = $this->getRootProperty();
46: if ($root_property instanceof TokenNode && $root_property->getType() === T_STRING) {
47: return $root_property->getText();
48: }
49: return NULL;
50: }
51:
52: 53: 54: 55: 56: 57: 58: 59: 60:
61: public function getRootProperty() {
62: if ($this->object instanceof ObjectPropertyNode) {
63: return $this->object->getRootProperty();
64: }
65: else {
66: return $this->property;
67: }
68: }
69: }
70: