Completed
Push — master ( ef103c...6c4a7c )
by Daniel
02:22
created

GitlabServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 44
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 29 1
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ServiceProvider;
4
5
use Gitlab\Client;
6
use Gitlab\HttpClient\Builder;
7
use Http\Client\Common\Plugin\CachePlugin;
8
use Http\Client\Common\Plugin\LoggerPlugin;
9
use Http\Client\HttpClient;
10
use Http\Discovery\StreamFactoryDiscovery;
11
use League\Container\Container;
12
use League\Container\ServiceProvider\AbstractServiceProvider;
13
use Psr\Cache\CacheItemPoolInterface;
14
use Psr\Log\LoggerInterface;
15
16
class GitlabServiceProvider extends AbstractServiceProvider
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected $provides = [
22
        LoggerPlugin::class,
23
        CachePlugin::class,
24
        Builder::class,
25
        Client::class,
26
    ];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    public function register()
32
    {
33
        /** @var Container $container */
34 1
        $container = $this->getContainer();
35
36 1
        $container->share(LoggerPlugin::class)
37 1
            ->addArgument(LoggerInterface::class);
38
39 1
        $container->share(CachePlugin::class)
40 1
            ->addArguments([
41 1
                CacheItemPoolInterface::class,
42 1
                StreamFactoryDiscovery::find(),
43
                [
44
                    'default_ttl' => 600,
45
                    'respect_response_cache_directives' => [],
46
                ]
47
            ]);
48
49 1
        $container->share(Builder::class)
50 1
            ->addArgument(HttpClient::class)
51 1
            ->addMethodCall('addPlugin', [LoggerPlugin::class])
52 1
            ->addMethodCall('addPlugin', [CachePlugin::class]);
53
54 1
        $container->share(Client::class)
55 1
            ->addArgument(Builder::class)
56 1
            ->addMethodCall('setUrl', ['GITLAB_URL'])
57 1
            ->addMethodCall('authenticate', [
58 1
                'GITLAB_TOKEN',
59 1
                Client::AUTH_URL_TOKEN,
60
            ]);
61 1
    }
62
}
63