public function evaluate($subject, Policy $policy, array $addl = array())
{
$addl = array_merge([$subject], $addl);
$checks = $policy->getChecks();
if (empty($checks)) {
trigger_error('Policy evaluation was perfomed with no checks', E_USER_WARNING);
}
foreach ($checks as $type => $value) {
$propertyValue = $this->getPropertyValue($type, $subject);
if ($propertyValue == null && $type !== 'closure') {
throw new \InvalidArgumentException('Invalid property value for "' . $type . '"!');
}
$result = $this->executeTests($value, $type, $propertyValue, $addl);
// If we have a failure, return false...
if ($result === false) {
return false;
}
}
return true;
}