/** * Get the entity from the passed rule * * @param Rule $rule */ protected function getEntity(Rule $rule) { if ($rule instanceof RuleSet) { foreach ($rule->getChildren() as $child) { return $child->getEntity(); } throw new \Exception(sprintf('The rule %s and non of its children have an entity', get_class($rule))); } return $rule->getEntity(); }
public function evaluate(Rule $rule) { if (is_array($rule->getLeft())) { return !in_array($rule->getRight(), $rule->getLeft()); } else { return false === strpos($rule->getLeft(), $rule->getRight()) ? true : false; } }
public function evaluate(Rule $rule) { return $rule->getLeft() > $rule->getRight(); }
/** * When both sides are array, it will determine if ALL of $rule->getRight()'s items * are inside the $param. * * @param Opifer\RulesEngine\Rule\Rule * @return boolean */ public function evaluate(Rule $rule) { if (is_array($rule->getLeft()) && is_array($rule->getRight())) { $intersect = array_intersect($rule->getLeft(), $rule->getRight()); if (array_diff($rule->getRight(), $intersect)) { return false; } return true; } elseif (is_array($rule->getLeft()) && !is_array($rule->getRight())) { return in_array($rule->getRight(), $rule->getLeft()); } elseif (!is_array($rule->getLeft()) && is_array($rule->getRight())) { return in_array($rule->getLeft(), $rule->getRight()); } return false; }
/** * Evaluate * * @param Rule $rule * * @return EnvironmentInterface */ public function evaluate(Rule $rule) { $rule->evaluate($this); return $this; }
public function evaluate(Rule $rule) { return preg_match($rule->getLeft(), $rule->getRight()) ? true : false; }