Elgg\HooksRegistrationService::getMatcher PHP Method

getMatcher() protected method

Create a matcher for the given callable (if it's for a static or dynamic method)
protected getMatcher ( callable $spec ) : elgg\MethodMatcher | null
$spec callable Callable we're creating a matcher for
return elgg\MethodMatcher | null
    protected function getMatcher($spec)
    {
        if (is_string($spec) && false !== strpos($spec, '::')) {
            list($type, $method) = explode('::', $spec, 2);
            return new MethodMatcher($type, $method);
        }
        if (!is_array($spec) || empty($spec[0]) || empty($spec[1]) || !is_string($spec[1])) {
            return null;
        }
        if (is_object($spec[0])) {
            $spec[0] = get_class($spec[0]);
        }
        if (!is_string($spec[0])) {
            return null;
        }
        return new MethodMatcher($spec[0], $spec[1]);
    }