Ejemplo n.º 1
0
 /**
  * Internal function to retrieve the value from $item for $attribute and check
  * if the given rule complies.
  *
  * Return false, if the $item does not have an property $attribute
  *
  * @param Rule $rule
  * @param $item
  * @param $attribute
  * @return bool
  */
 protected function check_attribute(Rule $rule, $item, $attribute)
 {
     $value = null;
     if (is_object($item) && isset($item->{$attribute})) {
         $value = $item->{$attribute};
     }
     if (is_array($item) && isset($item[$attribute])) {
         $value = $item[$attribute];
     }
     if ($value === null || !$rule->check($value)) {
         $this->failedRule = $rule;
         return false;
     }
     return true;
 }