/** * @throws WrongArgumentException * @return LogicalChain **/ public static function getOpenPoint($left, $right, $point) { Assert::isFalse($point === null, 'how can i build logic from emptyness?'); $point = new DBValue($point); $chain = new LogicalChain(); $chain->expOr(Expression::orBlock(Expression::andBlock(Expression::notNull($left), Expression::notNull($right), Expression::between($point, $left, $right)), Expression::andBlock(Expression::isNull($left), Expression::ltEq($point, $right)), Expression::andBlock(Expression::isNull($right), Expression::ltEq($left, $point)), Expression::andBlock(Expression::isNull($left), Expression::isNull($right)))); return $chain; }
public function __construct($dao = null) { if ($dao) { Assert::isTrue($dao instanceof ProtoDAO); } $this->dao = $dao; $this->logic = Expression::andBlock(); $this->order = new OrderChain(); $this->strategy = FetchStrategy::join(); $this->projection = Projection::chain(); }
public function testFormCalculation() { $form = Form::create()->add(Primitive::string('a'))->add(Primitive::boolean('b'))->add(Primitive::integer('c'))->add(Primitive::integer('d'))->add(Primitive::integer('e'))->add(Primitive::boolean('f'))->import(array('a' => 'asDfg', 'b' => 'true', 'c' => '1', 'd' => '2', 'e' => '3')); $this->assertTrue(Expression::isTrue(new FormField('b'))->toBoolean($form)); $this->assertFalse(Expression::isTrue(new FormField('f'))->toBoolean($form)); $this->assertFalse(Expression::eq('asdf', new FormField('a'))->toBoolean($form)); $this->assertTrue(Expression::eqLower('asdfg', new FormField('a'))->toBoolean($form)); $this->assertTrue(Expression::eq('asDfg', new FormField('a'))->toBoolean($form)); $this->assertTrue(Expression::andBlock(Expression::expOr(new FormField('b'), new FormField('f')), Expression::eq(7, Expression::add(new FormField('c'), Expression::mul(new FormField('d'), new FormField('e')))))->toBoolean($form)); $this->assertTrue(Expression::between(new FormField('d'), new FormField('c'), new FormField('e'))->toBoolean($form)); $this->assertFalse(Expression::between(new FormField('c'), new FormField('d'), new FormField('e'))->toBoolean($form)); $this->assertFalse(Expression::not(new FormField('b'))->toBoolean($form)); $this->assertTrue(Expression::not(new FormField('f'))->toBoolean($form)); }