public final function getInstance($requestedClass, ...$arguments)
    {
        if (isset($this->singletons[$requestedClass])){
            return $this->singletons[$requestedClass];
        }

        $useSingleton = false;

        // Check for singletons first as they should trump previous registrations of non
        // singleton mappings.
        if (isset($this->concreteClassMappings['_'.$requestedClass])) {
            $class = $this->concreteClassMappings['_'.$requestedClass];
            $useSingleton = true;
        } elseif (isset($this->concreteClassMappings[$requestedClass])){
            $class = $this->concreteClassMappings[$requestedClass];
        } else {
            $class = $requestedClass;
        }

        $reflection = new \ReflectionClass($class);

        if ($reflection->isAbstract()){
            throw new ClassMappingException($class);
        }

        $constructor = $reflection->getConstructor();

        if ($constructor == null){
            // No defined constructor so exit simply with a new instance.
            $instance = $reflection->newInstanceArgs($arguments);
        } else {
            $instance = $this->generateInstanceFromConstructor($reflection, $constructor, $arguments);
        }

        if ($useSingleton) {
            $this->singletons[$requestedClass] = $instance;
        }

        return $instance;
    }