AssetComposer.php
public function compose($single = false)
    {
        $reflection = new \ReflectionClass($this->class);

        $constructArgs  = $this->constructArgs;
        $methodArgs     = $this->methodArgs;

        if ($single) {
            static $obj;
            if ($obj == null) {
                $obj = (new Asset($this->class))->single(
                    function () use ($reflection, $constructArgs, $methodArgs) {
                        if ($constructArgs) {
                            $object = $reflection->newInstanceArgs($constructArgs);
                        } else {
                            $object = $reflection->newInstance();
                        }

                        foreach ($methodArgs as $method => $params) {
                            if ($reflection->hasMethod($method)) {
                                call_user_func_array([$object, $method], $params);
                            }
                        }
                        return $object;
                    }
                );
            }
            return $obj;
        } else {
            return new Asset(
                $this->class,
                function () use ($reflection, $constructArgs, $methodArgs) {
                    if ($constructArgs) {
                        $object = $reflection->newInstanceArgs($constructArgs);
                    } else {
                        $object = $reflection->newInstance();
                    }

                    foreach ($methodArgs as $method => $params) {
                        if ($reflection->hasMethod($method)) {
                            call_user_func_array([$object, $method], $params);
                        }
                    }
                    return $object;
                }
            );
        }
    }
public function compose($single = false)
    {
        $reflection = new \ReflectionClass($this->class);

        $constructArgs  = $this->constructArgs;
        $methodArgs     = $this->methodArgs;

        if ($single) {
            static $obj;
            if ($obj == null) {
                $obj = (new Asset($this->class))->single(
                    function () use ($reflection, $constructArgs, $methodArgs) {
                        if ($constructArgs) {
                            $object = $reflection->newInstanceArgs($constructArgs);
                        } else {
                            $object = $reflection->newInstance();
                        }

                        foreach ($methodArgs as $method => $params) {
                            if ($reflection->hasMethod($method)) {
                                call_user_func_array([$object, $method], $params);
                            }
                        }
                        return $object;
                    }
                );
            }
            return $obj;
        } else {
            return new Asset(
                $this->class,
                function () use ($reflection, $constructArgs, $methodArgs) {
                    if ($constructArgs) {
                        $object = $reflection->newInstanceArgs($constructArgs);
                    } else {
                        $object = $reflection->newInstance();
                    }

                    foreach ($methodArgs as $method => $params) {
                        if ($reflection->hasMethod($method)) {
                            call_user_func_array([$object, $method], $params);
                        }
                    }
                    return $object;
                }
            );
        }
    }
public function compose ( $ single = false ) { $ reflection = new \ ReflectionClass ( $ this -> class ) ; $ constructArgs = $ this -> constructArgs ; $ methodArgs = $ this -> methodArgs ; if ( $ single ) { static $ obj ; if ( $ obj == null ) { $ obj = ( new Asset ( $ this -> class ) ) -> single ( function ( ) use ( $ reflection , $ constructArgs , $ methodArgs ) { if ( $ constructArgs ) { $ object = $ reflection -> newInstanceArgs ( $ constructArgs ) ; } else { $ object = $ reflection -> newInstance ( ) ; } foreach ( $ methodArgs as $ method => $ params ) { if ( $ reflection -> hasMethod ( $ method ) ) { call_user_func_array ( [ $ object , $ method ] , $ params ) ; } } return $ object ; } ) ; } return $ obj ; } else { return new Asset ( $ this -> class , function ( ) use ( $ reflection , $ constructArgs , $ methodArgs ) { if ( $ constructArgs ) { $ object = $ reflection -> newInstanceArgs ( $ constructArgs ) ; } else { $ object = $ reflection -> newInstance ( ) ; } foreach ( $ methodArgs as $ method => $ params ) { if ( $ reflection -> hasMethod ( $ method ) ) { call_user_func_array ( [ $ object , $ method ] , $ params ) ; } } return $ object ; } ) ; } }
Build a configured Asset and return it.

This Asset can optionally be returned implementing a singleton.

@param bool $single
@return Proem\Service\AssetInterface
Build a configured Asset and return it .