private function createInstanceFromArguments($className, array $arguments)
    {
        $reflection = new \ReflectionClass($className);
        $constructor = $reflection->getConstructor();

        // There is no or at least a non-accessible constructor for provided class name,
        // therefore there is no need to handle arguments anyway
        if ($constructor === null) {
            return $reflection->newInstanceArgs($arguments);
        }

        if (!$constructor->isPublic()) {
            throw new \InvalidArgumentException(sprintf(
                '%s::__construct is not accessible',
                $className
            ));
        }

        $requiredArgsCount = $constructor->getNumberOfRequiredParameters();
        $argumentCount = count($arguments);

        if ($requiredArgsCount > $argumentCount) {
            throw new \InvalidArgumentException(sprintf(
                '%s::__construct() requires at least %d arguments; %d given',
                $className,
                $requiredArgsCount,
                $argumentCount
            ));
        }

        // Arguments supposed to be ordered
        if (isset($arguments[0])) {
            return $reflection->newInstanceArgs($arguments);
        }

        $parameters = array();

        foreach ($constructor->getParameters() as $parameter) {
            $parameterName = $parameter->getName();

            if (array_key_exists($parameterName, $arguments)) {
                $parameters[$parameter->getPosition()] = $arguments[$parameterName];
                continue;
            }

            if (!$parameter->isOptional()) {
                throw new \InvalidArgumentException(sprintf(
                    'Missing at least one required parameters `%s`',
                    $parameterName
                ));
            }

            $parameters[$parameter->getPosition()] = $parameter->getDefaultValue();
        }

        return $reflection->newInstanceArgs($parameters);
    }