You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
950 B
PHTML
39 lines
950 B
PHTML
5 years ago
|
<?php
|
||
|
|
||
|
|
||
|
namespace Gitlab\Api;
|
||
|
|
||
|
|
||
|
use Gitlab\Api\Plugin\Authentication;
|
||
|
use Http\Client\Common\Plugin\AddHostPlugin;
|
||
|
use Http\Client\Common\Plugin\AddPathPlugin;
|
||
|
use Http\Client\Common\PluginClient;
|
||
|
use Http\Client\HttpAsyncClient;
|
||
|
use Http\Discovery\UriFactoryDiscovery;
|
||
|
use Http\Message\UriFactory;
|
||
|
|
||
|
class ClientFactory
|
||
|
{
|
||
|
public static function create(
|
||
|
HttpAsyncClient $client,
|
||
|
Authentication $authentication,
|
||
|
string $host
|
||
|
) : PluginClient
|
||
|
{
|
||
|
/**
|
||
|
* @var UriFactory
|
||
|
*/
|
||
|
$uriFactory = UriFactoryDiscovery::find();
|
||
|
|
||
|
$plugins = [
|
||
|
$authentication,
|
||
|
// Prepend api version to path
|
||
|
new AddPathPlugin($uriFactory->createUri('/api/v4/')),
|
||
|
// Make sure host is set to the right uri
|
||
|
new AddHostPlugin($uriFactory->createUri($host), ['replace' => true]),
|
||
|
|
||
|
];
|
||
|
|
||
|
return new PluginClient($client, $plugins);
|
||
|
}
|
||
|
}
|