public function createInstance($className, array $args = null)
    {

        $args = $args ? $args : [];
        $className = $this->resolveClassName($className);

        if (!class_exists($className) || ($this->_baseClassName && !is_subclass_of($className, $this->_baseClassName)))
            throw new FactoryException(
                "Failed to resolve factory classname: "
                ."$className does not exist or is not a valid {$this->_baseClassName}"
            );

        $ref = new \ReflectionClass($className);

        return $ref->newInstanceArgs($args);
    }
public function createInstance($className, array $args = null)
    {

        $args = $args ? $args : [];
        $className = $this->resolveClassName($className);

        if (!class_exists($className) || ($this->_baseClassName && !is_subclass_of($className, $this->_baseClassName)))
            throw new FactoryException(
                "Failed to resolve factory classname: "
                ."$className does not exist or is not a valid {$this->_baseClassName}"
            );

        $ref = new \ReflectionClass($className);

        return $ref->newInstanceArgs($args);
    }
public function createInstance ( $ className , array $ args = null ) { $ args = $ args ? $ args : [ ] ; $ className = $ this -> resolveClassName ( $ className ) ; if ( ! class_exists ( $ className ) || ( $ this -> _baseClassName && ! is_subclass_of ( $ className , $ this -> _baseClassName ) ) ) throw new FactoryException ( "Failed to resolve factory classname: " . "$className does not exist or is not a valid {$this->_baseClassName}" ) ; $ ref = new \ ReflectionClass ( $ className ) ; return $ ref -> newInstanceArgs ( $ args ) ; }
Creates a new instance of a class based on a class name or alias given.

If the class doesnt exist or doesnt extend the base-class of this factory,
a RuntimeException is thrown

Uses Reflection internally

@see ReflectionClass->newInstanceArgs

@param string     $className The alias or FQCN to instanciate
@param array|null $args      The arguments that should be passed to the constructor

@throws \Tale\FactoryException

@return object The newly created child-class instance
Creates a new instance of a class based on a class name or alias given .