src/Register.php
public function factory($namespace, array $args = [])
    {
        $namespace = $this->checkOverrider($namespace);

        $this->classExists($namespace)
            ->callEvent('register_before_create', [$namespace, $args]);

        try {
            $object = new $namespace(...$args);
        } catch (\Exception $exception) {
            throw new RegisterException($exception);
        }

        $this->callEvent('register_after_create', [$object]);

        $this->setClassCounter($namespace);
        $this->registeredObjects[$namespace] = get_class($object);

        $this->makeLog([
            'Object created: ' . $namespace . '. With args:',
            $args
        ]);

        return $object;
    }
public function factory($namespace, array $args = [])
    {
        $namespace = $this->checkOverrider($namespace);

        $this->classExists($namespace)
            ->callEvent('register_before_create', [$namespace, $args]);

        try {
            $object = new $namespace(...$args);
        } catch (\Exception $exception) {
            throw new RegisterException($exception);
        }

        $this->callEvent('register_after_create', [$object]);

        $this->setClassCounter($namespace);
        $this->registeredObjects[$namespace] = get_class($object);

        $this->makeLog([
            'Object created: ' . $namespace . '. With args:',
            $args
        ]);

        return $object;
    }
public function factory ( $ namespace , array $ args = [ ] ) { $ namespace = $ this -> checkOverrider ( $ namespace ) ; $ this -> classExists ( $ namespace ) -> callEvent ( 'register_before_create' , [ $ namespace , $ args ] ) ; try { $ object = new $ namespace ( ... $ args ) ; } catch ( \ Exception $ exception ) { throw new RegisterException ( $ exception ) ; } $ this -> callEvent ( 'register_after_create' , [ $ object ] ) ; $ this -> setClassCounter ( $ namespace ) ; $ this -> registeredObjects [ $ namespace ] = get_class ( $ object ) ; $ this -> makeLog ( [ 'Object created: ' . $ namespace . '. With args:' , $ args ] ) ; return $ object ; }
create new instance of given class

@param string $namespace
@param array $args
@return mixed
@throws \InvalidArgumentException
@throws RegisterException
create new instance of given class