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

ConfigurationServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 38
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 13 2
A register() 0 2 1
1
<?php declare(strict_types=1);
2
3
namespace DanielPieper\MergeReminder\ServiceProvider;
4
5
use League\Container\Container;
6
use League\Container\ServiceProvider\AbstractServiceProvider;
7
use League\Container\ServiceProvider\BootableServiceProviderInterface;
8
9
class ConfigurationServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    protected $provides = [
15
        'GITLAB_URL',
16
        'GITLAB_TOKEN',
17
        'SLACK_WEBHOOK_URL',
18
        'SLACK_CHANNEL',
19
    ];
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function register()
25
    {
26
    }
27
28
    /**
29
     * Method will be invoked on registration of a service provider implementing
30
     * this interface. Provides ability for eager loading of Service Providers.
31
     *
32
     * @return void
33
     */
34 1
    public function boot()
35
    {
36 1
        $dotEnv = \Dotenv\Dotenv::create(__DIR__ . '../..');
37 1
        $dotEnv->safeLoad();
38 1
        $dotEnv->required(['GITLAB_TOKEN'])->notEmpty();
39
40
        /** @var Container $container */
41 1
        $container = $this->getContainer();
42
43 1
        $container->add('SLACK_WEBHOOK_URL', getenv('SLACK_WEBHOOK_URL'));
44 1
        $container->add('SLACK_CHANNEL', getenv('SLACK_CHANNEL'));
45 1
        $container->add('GITLAB_TOKEN', getenv('GITLAB_TOKEN'));
46 1
        $container->add('GITLAB_URL', (getenv('GITLAB_URL') ? getenv('GITLAB_URL') : 'https://gitlab.com'));
47 1
    }
48
}
49