/** * @param string $operand * @return File */ public function __construct($operator, $operand, $isParentheses = false) { $this->setOperator($operator); parent::__construct($operand, $isParentheses); }
/** * Because we are extending the BasicExpr our left operand is its only * only operand so we will reuse that and only write a setter for the * right * * @param string | object $leftOp * @param string $operator * @parma string | object $rightOp * @param bool $isPar flag or using parentheses * @return BinaryExpr */ public function __construct($leftOp, $operator, $rightOp, $isPar = false) { $this->setOperator($operator); $this->setRightOperand($rightOp); parent::__construct($leftOp, $isPar); }
/** * @return null */ public function testIsEnableDisableParentheses() { $op = 'my value'; $expr = new BasicExpr($op); $this->assertFalse($expr->isParentheses()); $this->assertSame($expr, $expr->enableParentheses()); $this->assertTrue($expr->isParentheses()); $expected = "({$op})"; $this->assertEquals($expected, $expr->build()); $this->assertSame($expr, $expr->disableParentheses()); $this->assertFalse($expr->isParentheses()); $this->assertEquals($op, $expr->build()); $expr = new BasicExpr($op, true); $this->assertTrue($expr->isParentheses()); $this->assertEquals($expected, $expr->build()); }