Ejemplo n.º 1
0
 public function __call($name, $arguments)
 {
     if ('is' === substr($name, 0, 2)) {
         $pattern = preg_replace(array('/^is/', '/_/'), array('', '.?'), $name);
         $pattern = preg_replace_callback('/([A-Z])([a-z]+)/', function ($matches) {
             return '.?' . strtolower($matches[1]) . $matches[2];
         }, $pattern);
         $pattern = '/^' . $pattern . '$/i';
         if (1 === count($arguments)) {
             return $this->matches($pattern, $arguments[0]);
         }
         return $this->matches($pattern);
     }
     return parent::__call($name, $arguments);
 }
Ejemplo n.º 2
0
 public function __call($method, $arguments)
 {
     $assertion = null;
     switch ($method) {
         case '<=':
             $assertion = 'isLessThanOrEqualTo';
             break;
         case '<':
             $assertion = 'isLessThan';
             break;
         case '>=':
             $assertion = 'isGreaterThanOrEqualTo';
             break;
         case '>':
             $assertion = 'isGreaterThan';
             break;
         default:
             return parent::__call($method, $arguments);
     }
     return call_user_func_array(array($this, $assertion), $arguments);
 }