Inpsyde\MultilingualPress\Factory\GenericFactory::create PHP Method

create() public method

Returns a new object of the given (or default) class, instantiated with the given arguments.
Since: 3.0.0
public create ( array $args = [], string $class = '' ) : object
$args array Optional. Constructor arguments. Defaults to empty array.
$class string Optional. Fully qualified class name. Defaults to empty string.
return object Object of the given (or default) class, instantiated with the given arguments.
    public function create(array $args = [], $class = '')
    {
        if ($class) {
            $this->check_class($class);
            $class = (string) $class;
        } else {
            $class = $this->default_class;
        }
        switch (count($args)) {
            case 0:
                return new $class();
            case 1:
                return new $class($args[0]);
        }
        return (new ReflectionClass($class))->newInstanceArgs($args);
    }