Hal\Pattern\Resolver\Structural\Decorator\DecoratorResolver::resolve PHP Method

resolve() public method

extends one class, has one public method receive one argument and call this argument
public resolve ( Hal\Pattern\Resolver\ResolvedClass $resolved )
$resolved Hal\Pattern\Resolver\ResolvedClass
    public function resolve(ResolvedClass $resolved)
    {
        $class = $resolved->getClass();
        $pattern = new Decorator($class->getFullname());
        // extends one class
        if (!$class->getParent()) {
            return;
        }
        // exclude magical methods
        $collection = (new Collection($class->getMethods()))->where('method => !isMagicMethod(method)');
        // class should have only one public method
        $collection->where('method => method.getVisibility() == "public"');
        if (sizeof($collection) != 1) {
            return;
        }
        // receive one argument
        $collection->where('count(method.getArguments()) == 1');
        if (sizeof($collection) != 1) {
            return;
        }
        // call received argument
        $method = $collection->first();
        foreach ($method->getArguments() as $argument) {
            if (in_array($argument->getName(), $method->getExternalCalls())) {
                $pattern->setDecorated($argument->getType());
                $resolved->pushPattern($pattern);
                return;
            }
        }
    }
DecoratorResolver