public function create(string $serviceName, array $args = [])
    {
        if (!$this->registry->has($serviceName)) {
            throw new \LogicException(sprintf('The service "%s" is not registered.', $serviceName));
        }

        $classOrCallable = $this->registry->get($serviceName);

        if (is_callable($classOrCallable)) {
            return call_user_func($classOrCallable);
        }

        if (is_subclass_of($classOrCallable, HttpService::class)) {
            return new $classOrCallable($this->httpClient, $this->requestFactory, $args);
        }

        $r = new \ReflectionClass($classOrCallable);

        return $r->newInstanceArgs($args);
    }
public function create(string $serviceName, array $args = [])
    {
        if (!$this->registry->has($serviceName)) {
            throw new \LogicException(sprintf('The service "%s" is not registered.', $serviceName));
        }

        $classOrCallable = $this->registry->get($serviceName);

        if (is_callable($classOrCallable)) {
            return call_user_func($classOrCallable);
        }

        if (is_subclass_of($classOrCallable, HttpService::class)) {
            return new $classOrCallable($this->httpClient, $this->requestFactory, $args);
        }

        $r = new \ReflectionClass($classOrCallable);

        return $r->newInstanceArgs($args);
    }
public function create ( string $ serviceName , array $ args = [ ] ) { if ( ! $ this -> registry -> has ( $ serviceName ) ) { throw new \ LogicException ( sprintf ( 'The service "%s" is not registered.' , $ serviceName ) ) ; } $ classOrCallable = $ this -> registry -> get ( $ serviceName ) ; if ( is_callable ( $ classOrCallable ) ) { return call_user_func ( $ classOrCallable ) ; } if ( is_subclass_of ( $ classOrCallable , HttpService :: class ) ) { return new $ classOrCallable ( $ this -> httpClient , $ this -> requestFactory , $ args ) ; } $ r = new \ ReflectionClass ( $ classOrCallable ) ; return $ r -> newInstanceArgs ( $ args ) ; }
Creates a new service.

@param string $serviceName
@param array  $args

@return \Exchanger\Contract\ExchangeRateService
Creates a new service .