/** * Evaluate the given set of policies against the subject * * @param Subject $subject Current subject * @param PolicySet $policySet Set of policies * @param Action $action * * @return bool */ public function evaluate(Subject $subject, PolicySet $policySet, Action $action) { // get the subject's attributes $this->setSubjectAttributes($subject->getAttributes()); $policyResults = $this->handlePolicies($policySet->getPolicies()); if (count($policyResults) == 1) { return array_shift($policyResults); } else { // we're working with a set of policies, go with the algorithm // if we have one... $algorithm = $policySet->getAlgorithm(); if ($algorithm === null) { // default to most secure - deny overrides! $algorithm = new Algorithm\DenyOverrides(); } return $algorithm = $algorithm->evaluate($policyResults); } }