Determines if a given method can be called.
public static respondsTo ( string $method, boolean $internal = false ) : boolean | ||
$method | string | Name of the method. |
$internal | boolean | Provide `true` to perform check from inside the class/object. When `false` checks also for public visibility; defaults to `false`. |
리턴 | boolean | Returns `true` if the method can be called, `false` otherwise. |
/** * Custom check to determine if our given magic methods can be responded to. * * @param string $method Method name. * @param bool $internal Interal call or not. * @return bool */ public static function respondsTo($method, $internal = false) { return isset(static::$_tags[$method]) || parent::respondsTo($method, $internal); }
/** * Determines if a given method can be called. * * @param string $method Name of the method. * @param boolean $internal Provide `true` to perform check from inside the * class/object. When `false` checks also for public visibility; * defaults to `false`. * @return boolean Returns `true` if the method can be called, `false` otherwise. */ public static function respondsTo($method, $internal = false) { $self = static::_object(); $methods = static::instanceMethods(); $isFinder = isset($self->_finders[$method]); preg_match('/^findBy(?P<field>\\w+)$|^find(?P<type>\\w+)By(?P<fields>\\w+)$/', $method, $args); $staticRepondsTo = $isFinder || $method === 'all' || !!$args; $instanceRespondsTo = isset($methods[$method]); return $instanceRespondsTo || $staticRepondsTo || parent::respondsTo($method, $internal); }
/** * Custom check to determine if our given magic methods can be responded to. * * @param string $method Method name. * @param bool $internal Interal call or not. * @return bool */ public static function respondsTo($method, $internal = false) { $rule = preg_replace("/^is([A-Z][A-Za-z0-9]+)\$/", '$1', $method); $rule[0] = strtolower($rule[0]); return isset(static::$_rules[$rule]) || parent::respondsTo($method, $internal); }