Build HTTP Browser (Transporter) from given arguments

@param $client
@param array $configuration
@param array $constructorArguments

@return Browser
342427
public static function buildTransporter($client, array $configuration = [], array $constructorArguments = [])
    {
        return new Browser(self::buildClient($client, $configuration, $constructorArguments), null);
    }
461410
public function buildProvider($provider, $config)
    {
        $provider = new $provider(
            $this->app['request'], $config['client_id'],
            $config['client_secret'], $config['redirect_uri']
        );

        $provider->setBaseURL($config['tokenpass_url']);

        return $provider;
    }
463474
private function buildClient(
        RequestFactoryInterface $factory,
        SenderInterface $sender,
        LoggerInterface $logger,
        $service
    ) {
        return $service !== null
            ? new ServiceClient($factory, $sender, $logger, $service)
            : new MultiClient($factory, $sender, $logger);
    }
1246067
private function getClient() {
        $login = $this->getParam('login');
        $password = $this->getParam('password');

        if (empty($login) || empty($password)) {
            throw new ConfigurationException(__CLASS__ . ' is not configured properly. Please set "login" and "password" parameters properly.');
        }

        return new SerwerSMS($login, $password);
    }
190030
@Bean
    public ArmeriaClientConfigurator armeriaClientConfigurator(ClientFactory clientFactory) {
        // Customize the client using the given HttpClientBuilder. For example:
        return builder -> {
            // Use a circuit breaker for each remote host.
            final CircuitBreakerStrategy strategy = CircuitBreakerStrategy.onServerErrorStatus();
            builder.decorator(new CircuitBreakerHttpClientBuilder(strategy).newDecorator());

            // Set a custom client factory.
            builder.factory(clientFactory);
        };
    }
1094134
private function getDomainRequestHandler( ServesUriComponents $uriComponents, ServesRequestData $request )
	{
		$domainNamespace = $this->config->getDomainNamespace();
		$requestInfo     = $this->config->getRequestInfo();

		$builder = new DomainRequestHandlerBuilder(
				$domainNamespace,
				$requestInfo->getMethod(),
			$uriComponents
		);

		$domainRequestHandler = $builder->buildDomainRequestHandler( $request );

		return $domainRequestHandler;
	}
578778
public function createDriver(BrowserConfiguration $browser)
	{
		if ( !class_exists('Behat\Mink\Driver\Selenium2Driver') ) {
			throw new \RuntimeException(
				'Install MinkSelenium2Driver in order to use selenium2 driver.'
			);
		}

		$browser_name = $browser->getBrowserName();
		$capabilities = $browser->getDesiredCapabilities();
		$capabilities['browserName'] = $browser_name;

		// TODO: Maybe doesn't work!
		ini_set('default_socket_timeout', $browser->getTimeout());

		$driver = new \Behat\Mink\Driver\Selenium2Driver(
			$browser_name,
			$capabilities,
			'http://' . $browser->getHost() . ':' . $browser->getPort() . '/wd/hub'
		);

		return $driver;
	}
372164
protected function getAdapter(MongoClient $client, array $config)
    {
        $fs = $client->selectDB($config['database'])->getGridFS();

        return new GridFSAdapter($fs);
    }
537390
protected function buildConstructorInjectionCode(Configuration $objectConfiguration)
    {
        $assignments = [];

        $argumentConfigurations = $objectConfiguration->getArguments();
        $constructorParameterInfo = $this->reflectionService->getMethodParameters($objectConfiguration->getClassName(), '__construct');
        $argumentNumberToOptionalInfo = [];
        foreach ($constructorParameterInfo as $parameterInfo) {
            $argumentNumberToOptionalInfo[($parameterInfo['position'] + 1)] = $parameterInfo['optional'];
        }

        $highestArgumentPositionWithAutowiringEnabled = -1;
        /** @var ConfigurationArgument $argumentConfiguration */
        foreach ($argumentConfigurations as $argumentNumber => $argumentConfiguration) {
            if ($argumentConfiguration === null) {
                continue;
            }
            $argumentPosition = $argumentNumber - 1;
            if ($argumentConfiguration->getAutowiring() === Configuration::AUTOWIRING_MODE_ON) {
                $highestArgumentPositionWithAutowiringEnabled = $argumentPosition;
            }

            $argumentValue = $argumentConfiguration->getValue();
            $assignmentPrologue = 'if (!array_key_exists(' . ($argumentNumber - 1) . ', $arguments)) $arguments[' . ($argumentNumber - 1) . '] = ';
            if ($argumentValue === null && isset($argumentNumberToOptionalInfo[$argumentNumber]) && $argumentNumberToOptionalInfo[$argumentNumber] === true) {
                $assignments[$argumentPosition] = $assignmentPrologue . 'NULL';
            } else {
                switch ($argumentConfiguration->getType()) {
                    case ConfigurationArgument::ARGUMENT_TYPES_OBJECT:
                        if ($argumentValue instanceof Configuration) {
                            $argumentValueObjectName = $argumentValue->getObjectName();
                            $argumentValueClassName = $argumentValue->getClassName();
                            if ($argumentValueClassName === null) {
                                $preparedArgument = $this->buildCustomFactoryCall($argumentValue->getFactoryObjectName(), $argumentValue->getFactoryMethodName(), $argumentValue->getArguments());
                                $assignments[$argumentPosition] = $assignmentPrologue . $preparedArgument;
                            } else {
                                if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === Configuration::SCOPE_PROTOTYPE) {
                                    $assignments[$argumentPosition] = $assignmentPrologue . 'new \\' . $argumentValueObjectName . '(' . $this->buildMethodParametersCode($argumentValue->getArguments()) . ')';
                                } else {
                                    $assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')';
                                }
                            }
                        } else {
                            if (strpos($argumentValue, '.') !== false) {
                                $settingPath = explode('.', $argumentValue);
                                $settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath));
                                $argumentValue = Arrays::getValueByPath($settings, $settingPath);
                            }
                            if (!isset($this->objectConfigurations[$argumentValue])) {
                                throw new ObjectException\UnknownObjectException('The object "' . $argumentValue . '" which was specified as an argument in the object configuration of object "' . $objectConfiguration->getObjectName() . '" does not exist.', 1264669967);
                            }
                            $assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')';
                        }
                        break;

                    case ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE:
                        $assignments[$argumentPosition] = $assignmentPrologue . var_export($argumentValue, true);
                        break;

                    case ConfigurationArgument::ARGUMENT_TYPES_SETTING:
                        $assignments[$argumentPosition] = $assignmentPrologue . '\Neos\Flow\Core\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))';
                        break;
                }
            }
        }

        for ($argumentCounter = count($assignments) - 1; $argumentCounter > $highestArgumentPositionWithAutowiringEnabled; $argumentCounter--) {
            unset($assignments[$argumentCounter]);
        }

        $code = $argumentCounter >= 0 ? "\n        " . implode(";\n        ", $assignments) . ";\n" : '';

        $index = 0;
        foreach ($constructorParameterInfo as $parameterName => $parameterInfo) {
            if ($parameterInfo['optional'] === true) {
                break;
            }
            if ($objectConfiguration->getScope() === Configuration::SCOPE_SINGLETON) {
                $code .= '        if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Please check your calling code and Dependency Injection configuration.\', 1296143787);' . "\n";
            } else {
                $code .= '        if (!array_key_exists(' . $index . ', $arguments)) throw new \Neos\Flow\ObjectManagement\Exception\UnresolvedDependenciesException(\'Missing required constructor argument $' . $parameterName . ' in class \' . __CLASS__ . \'. Note that constructor injection is only support for objects of scope singleton (and this is not a singleton) – for other scopes you must pass each required argument to the constructor yourself.\', 1296143788);' . "\n";
            }
            $index++;
        }

        return $code;
    }
220317
public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $processedConfiguration = $this->processConfiguration($configuration, $configs);
        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.xml');

        $this->passConfigurationToOptions($container, $processedConfiguration);

        $container->getDefinition(ClientBuilderInterface::class)
            ->setConfigurator([ClientBuilderConfigurator::class, 'configure']);

        foreach ($processedConfiguration['listener_priorities'] as $key => $priority) {
            $container->setParameter('sentry.listener_priorities.' . $key, $priority);
        }

        $this->tagConsoleErrorListener($container);
    }
1159510
public function createConstructor(array $params)
    {
        $url = self::resolveFullUrl([$this->id, 'constructor']);

        $options = [
            'json' => $params,
        ];

        return static::post($this->client, $url, $options);
    }
137866
private static function buildClient(array $config = []): GuzzleClient
    {
        $handlerStack = new HandlerStack(\GuzzleHttp\choose_handler());
        $handlerStack->push(Middleware::prepareBody(), 'prepare_body');
        $config = array_merge(['handler' => $handlerStack], $config);

        return new GuzzleClient($config);
    }
68096
public function getMpdf($constructorArgs = array()) 
    {
        $allConstructorArgs = $constructorArgs;
	    if($this->getAddDefaultConstructorArgs()) {
	        $allConstructorArgs = array(array_merge(array('utf-8', 'A4'), $allConstructorArgs));
	    }		

        $reflection = new \ReflectionClass('Mpdf\Mpdf');
        $mpdf = $reflection->newInstanceArgs($allConstructorArgs);

        return $mpdf;
    }
1057490
protected function getArgumentsFromConstructorArguments(ReflectionClass $class, array $constructorArguments)
    {
        $arguments = array();
        if (($constructorMethod = $class->getConstructor()) instanceof ReflectionMethod) {
            foreach ($constructorMethod->getParameters() as $parameter) {
                if (array_key_exists($parameter->getName(), $constructorArguments)) {
                    $arguments[] = $constructorArguments[$parameter->getName() ];
                } elseif ($parameter->isDefaultValueAvailable()) {
                    $arguments[] = $parameter->getDefaultValue();
                } else {
                    break;
                }
            }
        }

        return $arguments;
    }
995973
public static function configure(
        HttpClientConfigurator $httpClientConfigurator,
        Hydrator $hydrator = null,
        RequestBuilder $requestBuilder = null
    ): self {
        $httpClient = $httpClientConfigurator->createConfiguredClient();

        return new self($httpClient, $hydrator, $requestBuilder);
    }
255834
protected function createRequest($client, $userId, $request, array $scopes)
    {
        return (new ServerRequest)->withParsedBody(
            ['grant_type' => 'password',
            'client_id' => $client->id,
            'client_secret' => $client->secret,
            'username' => $request->get('email'),
            'password' => $request->get('password'),
            'user_id' => $userId,
            'scope' => implode(' ', $scopes)]
        );
    }
1304760
protected function constructObject(
        /*# string */ $class,
        array $constructorArguments
    ) {
        $invoke = false;
        $reflector = new \ReflectionClass($class);
        $constructor = $reflector->getConstructor();

        // dereference arguments
        $this->dereferenceArray($constructorArguments);

        // not constructor defined
        if (is_null($constructor)) {
            $instance = new $class();
            $invoke = true;

        // singleton
        } elseif (!$constructor->isPublic() &&
            method_exists($class, 'getInstance')) {
            $instance = $class::getInstance();
            $invoke = true;

        // normal class with constructor
        } else {
            $constructorArguments = $this->matchMethodArguments(
                $constructor->getParameters(),
                $constructorArguments
            );
            $instance = $reflector->newInstanceArgs($constructorArguments);
        }

        // __invoke() defined
        if ($invoke && count($constructorArguments) &&
            method_exists($class, '__invoke')) {
            $this->executeCallable(
                [$instance, '__invoke'],
                $constructorArguments
            );
        }

        return $instance;
    }