protected function createClass($className, $args)
    {
        if ($args === null) {
            return new $className;
        }
        if (!is_array($args)) {
            return new $className($args);
        }
        if (count(array_filter(array_keys($args), 'is_string')) > 0) {
            return new $className($args);
        } else {
            /**
             * @todo Use argument unpacking (`return new $className(...$args);`)
             *     when minimum PHP requirement is bumped to 5.6.
             */
            $reflection = new ReflectionClass($className);
            return $reflection->newInstanceArgs($args);
        }
    }
protected function createClass($className, $args)
    {
        if ($args === null) {
            return new $className;
        }
        if (!is_array($args)) {
            return new $className($args);
        }
        if (count(array_filter(array_keys($args), 'is_string')) > 0) {
            return new $className($args);
        } else {
            /**
             * @todo Use argument unpacking (`return new $className(...$args);`)
             *     when minimum PHP requirement is bumped to 5.6.
             */
            $reflection = new ReflectionClass($className);
            return $reflection->newInstanceArgs($args);
        }
    }
protected function createClass ( $ className , $ args ) { if ( $ args === null ) { return new $ className ; } if ( ! is_array ( $ args ) ) { return new $ className ( $ args ) ; } if ( count ( array_filter ( array_keys ( $ args ) , 'is_string' ) ) > 0 ) { return new $ className ( $ args ) ; } else { /**
             * @todo Use argument unpacking (`return new $className(...$args);`)
             *     when minimum PHP requirement is bumped to 5.6.
             */ $ reflection = new ReflectionClass ( $ className ) ; return $ reflection -> newInstanceArgs ( $ args ) ; } }
Create a class instance with given arguments.

How the constructor arguments are passed depends on its type:

- if null, no arguments are passed at all.
- if it's not an array, it's passed as a single argument.
- if it's an associative array, it's passed as a sing argument.
- if it's a sequential (numeric keys) array, it's

@param string $className The FQN of the class to instanciate.
@param mixed  $args      The constructor arguments.
@return mixed The created object.
Create a class instance with given arguments .