public function testToString() { $expr1 = new AndX(); $expr2 = new AndX(array(new GreaterThan(10), new EndsWith('.css'))); $expr3 = new AndX(array(new GreaterThan(10), new OrX(array(new Contains('foo'), new EndsWith('.css'))))); $this->assertSame('', $expr1->toString()); $this->assertSame('>10 && endsWith(".css")', $expr2->toString()); $this->assertSame('>10 && (contains("foo") || endsWith(".css"))', $expr3->toString()); }
private function traverseConjunction(AndX $expr) { $conjuncts1 = $expr->getConjuncts(); $conjuncts2 = array(); foreach ($conjuncts1 as $conjunct) { if ($conjunct = $this->traverse($conjunct)) { $conjuncts2[] = $conjunct; } } if ($conjuncts1 === $conjuncts2) { return $expr; } return $conjuncts2 ? new AndX($conjuncts2) : null; }