Kahlan\Plugin\Stub::find PHP Method

find() public static method

Finds a stub.
public static find ( mixed $references, string $method = null, array $args = null ) : object | null
$references mixed An instance or a fully namespaced class name. or an array of that.
$method string The method name.
$args array The required arguments.
return object | null Return the subbed method or `null` if not founded.
    public static function find($references, $method = null, $args = null)
    {
        $references = (array) $references;
        $stub = null;
        $refs = [];
        foreach ($references as $reference) {
            $hash = Suite::hash($reference);
            if (!isset(static::$_registered[$hash])) {
                continue;
            }
            $stubs = static::$_registered[$hash]->methods();
            if (!isset($stubs[$method])) {
                continue;
            }
            foreach ($stubs[$method] as $stub) {
                $call['name'] = $method;
                $call['args'] = $args;
                if ($stub->match($call)) {
                    return $stub;
                }
            }
        }
        return false;
    }