1: <?php
2: namespace Pharborist\Operators;
3:
4: use Pharborist\ExpressionNode;
5: use Pharborist\Node;
6: use Pharborist\ParentNode;
7:
8: /**
9: * A binary operation.
10: */
11: abstract class BinaryOperationNode extends ParentNode implements ExpressionNode {
12: /**
13: * @var ExpressionNode
14: */
15: protected $left;
16:
17: /**
18: * @var Node
19: */
20: protected $operator;
21:
22: /**
23: * @var ExpressionNode
24: */
25: protected $right;
26:
27: /**
28: * @return ExpressionNode
29: */
30: public function getLeftOperand() {
31: return $this->left;
32: }
33:
34: /**
35: * @param ExpressionNode $operand
36: * @return $this
37: */
38: public function setLeftOperand(ExpressionNode $operand) {
39: /** @var Node $operand */
40: $this->left->replaceWith($operand);
41: return $this;
42: }
43:
44: /**
45: * @return Node
46: */
47: public function getOperator() {
48: return $this->operator;
49: }
50:
51: /**
52: * @return ExpressionNode
53: */
54: public function getRightOperand() {
55: return $this->right;
56: }
57:
58: /**
59: * @param ExpressionNode $operand
60: * @return $this
61: */
62: public function setRightOperand(ExpressionNode $operand) {
63: /** @var Node $operand */
64: $this->right->replaceWith($operand);
65: return $this;
66: }
67: }
68: