private function parseConditionElement(DOMElement $conditionElement) { $operatorElements = $this->xpath->query(sprintf('*[namespace-uri() = "%s"]', self::XMLNS_LOADER), $conditionElement); $operators = array(); foreach ($operatorElements as $operatorElement) { $operatorParser = OperatorParserFactoryMethod::create($operatorElement->localName); $operators[] = $operatorParser->parse($operatorElement, $this->xpath); } switch (count($operators)) { case 0: return Boolean::true(); case 1: return $operators[0]; default: $and = new AndOp(); array_map(function ($operator) use($and) { $and->addOperand($operator); }, $operators); return $and; } }
/** * @test * @dataProvider trueProvider * * @param mixed $value */ public function trueNativeExpression($value) { $this->assertSame('true', $this->boolean->setValue($value)->getNativeExpression()); }
/** * Creates a new Rule * * @param Expression $condition * @param Action $action Performed action after subrules execution */ public function __construct(Expression $condition = null, Action $action = null) { $this->noAction = new NoAction(); $this->condition = $condition ?: Boolean::true(); $this->actions = array(self::BEFORE_RULE => null, self::BEFORE_SUBRULES => null, self::AFTER_SUBRULES => $action, self::AFTER_RULE => null); }