public function invoke(
        $obj,
        string $method,
        array $params = []
    ) {
        if (is_string($obj)) {
            //Attempt to retrieve object from
            //the container.
            $obj = $this->get($obj);
        } elseif (!is_object($obj)) {
            //Not a valid argument.
            throw new \Exception('Invalid object');
        }

        $map = $this->generateArgumentsMap(
            $obj,
            $method,
            $params
        );
        $mapParams = $this->getParamsFromMap($map);

        return $obj->$method(...$mapParams);
    }
public function invoke(
        $obj,
        string $method,
        array $params = []
    ) {
        if (is_string($obj)) {
            //Attempt to retrieve object from
            //the container.
            $obj = $this->get($obj);
        } elseif (!is_object($obj)) {
            //Not a valid argument.
            throw new \Exception('Invalid object');
        }

        $map = $this->generateArgumentsMap(
            $obj,
            $method,
            $params
        );
        $mapParams = $this->getParamsFromMap($map);

        return $obj->$method(...$mapParams);
    }
public function invoke ( $ obj , string $ method , array $ params = [ ] ) { if ( is_string ( $ obj ) ) { //Attempt to retrieve object from //the container. $ obj = $ this -> get ( $ obj ) ; } elseif ( ! is_object ( $ obj ) ) { //Not a valid argument. throw new \ Exception ( 'Invalid object' ) ; } $ map = $ this -> generateArgumentsMap ( $ obj , $ method , $ params ) ; $ mapParams = $ this -> getParamsFromMap ( $ map ) ; return $ obj -> $ method ( ... $ mapParams ) ; }
Calls an object method,
injecting its dependencies.

@param mixed  $obj
@param string $method
@param array  $params

@throws \Exception

@return mixed
Calls an object method injecting its dependencies .