diff --git a/More/ServiceLocator/ServiceLocator.php b/More/ServiceLocator/ServiceLocator.php index af2c861..52b5c5a 100644 --- a/More/ServiceLocator/ServiceLocator.php +++ b/More/ServiceLocator/ServiceLocator.php @@ -40,24 +40,7 @@ class ServiceLocator return $this->instantiated[$class]; } - $args = $this->services[$class]; - - switch (count($args)) { - case 0: - $object = new $class(); - break; - case 1: - $object = new $class($args[0]); - break; - case 2: - $object = new $class($args[0], $args[1]); - break; - case 3: - $object = new $class($args[0], $args[1], $args[2]); - break; - default: - throw new OutOfRangeException('Too many arguments given'); - } + $object = new $class(...$this->services[$class]); if (!$object instanceof Service) { throw new InvalidArgumentException('Could not register service: is no instance of Service');