1: <?php
2: namespace Pharborist\ControlStructures;
3:
4: use Pharborist\Node;
5: use Pharborist\NodeCollection;
6: use Pharborist\ParenTrait;
7: use Pharborist\StatementNode;
8: use Pharborist\ExpressionNode;
9: use Pharborist\TokenNode;
10:
11: /**
12: * An if control structure.
13: */
14: class IfNode extends StatementNode {
15: use ParenTrait;
16: use AltSyntaxTrait;
17:
18: /**
19: * @var ExpressionNode
20: */
21: protected $condition;
22:
23: /**
24: * @var Node
25: */
26: protected $then;
27:
28: /**
29: * @var TokenNode
30: */
31: protected $elseKeyword;
32:
33: /**
34: * @var TokenNode
35: */
36: protected $elseColon;
37:
38: /**
39: * @var Node
40: */
41: protected $else;
42:
43: /**
44: * @return ExpressionNode
45: */
46: public function getCondition() {
47: return $this->condition;
48: }
49:
50: /**
51: * @return Node
52: */
53: public function getThen() {
54: return $this->then;
55: }
56:
57: /**
58: * @return NodeCollection|ElseIfNode[]
59: */
60: public function getElseIfs() {
61: return new NodeCollection($this->childrenByInstance('\Pharborist\ControlStructures\ElseIfNode'), FALSE);
62: }
63:
64: /**
65: * The T_ELSE keyword token.
66: *
67: * @return TokenNode
68: */
69: public function getElseKeyword() {
70: return $this->elseKeyword;
71: }
72:
73: /**
74: * The colon ':' token when using alternative syntax.
75: *
76: * @return TokenNode
77: */
78: public function getElseColon() {
79: return $this->elseColon;
80: }
81:
82: /**
83: * @return Node
84: */
85: public function getElse() {
86: return $this->else;
87: }
88: }
89: