Webmozart\Expression\Logic\OrX::orX PHP Method

orX() public method

public orX ( Webmozart\Expression\Expression $expr )
$expr Webmozart\Expression\Expression
    public function orX(Expression $expr)
    {
        if ($expr instanceof AlwaysFalse) {
            return $this;
        } elseif ($expr instanceof AlwaysTrue) {
            return $expr;
        }
        foreach ($this->disjuncts as $disjunct) {
            if ($disjunct->equivalentTo($expr)) {
                return $this;
            }
        }
        $disjuncts = $this->disjuncts;
        if ($expr instanceof self) {
            $disjuncts = array_merge($disjuncts, $expr->disjuncts);
        } else {
            $disjuncts[] = $expr;
        }
        return new self($disjuncts);
    }

Usage Example

コード例 #1
0
 public function testOrXReturnsTrue()
 {
     $disjunction1 = new OrX(array($notNull = new Same('10')));
     $disjunction2 = $disjunction1->orX($true = new AlwaysTrue());
     $this->assertSame($true, $disjunction2);
 }