コード例 #1
0
ファイル: Gatekeeper.php プロジェクト: sdh100shaun/gatekeeper
 /**
  * Evaluate the policy (found by name) against the data provided
  *
  * @param string $name Name of the policy
  * @param mixed $data Data to use in evaluation (single object or array)
  * @return boolean Pass/fail status of evaluation
  */
 public static function evaluatePolicy($name, $data)
 {
     // See if it's a closure policy first
     if (array_key_exists($name, self::$policies)) {
         $policy = self::$policies[$name];
         $result = $policy($data);
         return !is_bool($result) ? false : $result;
     } else {
         $policy = Gatekeeper::findPolicyByName($name);
         return $policy->evaluate($data);
     }
 }