| 1 | <?php |
||
| 7 | class IfControlNode extends Node |
||
| 8 | { |
||
| 9 | protected Node $condition; |
||
|
|
|||
| 10 | protected Node $statement; |
||
| 11 | |||
| 12 | public function __construct(Node $condition, Node $statement) |
||
| 13 | { |
||
| 14 | $this->condition = $condition; |
||
| 15 | $this->statement = $statement; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function evaluate() |
||
| 19 | { |
||
| 20 | if ($this->condition->evaluate()) { |
||
| 21 | $this->statement->evaluate(); |
||
| 22 | |||
| 23 | return true; |
||
| 24 | } |
||
| 25 | |||
| 26 | return false; |
||
| 27 | } |
||
| 28 | } |
||
| 29 |