Completed
Push — master ( ac8bb1...1061f5 )
by Daniel
02:21
created

ConfigurationServiceProvider::boot()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 10
cp 0
crap 6
rs 10
c 0
b 0
f 0
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
    public function boot()
35
    {
36
        $dotEnv = \Dotenv\Dotenv::create(__DIR__ . '../..');
37
        $dotEnv->safeLoad();
38
        $dotEnv->required(['GITLAB_TOKEN'])->notEmpty();
39
40
        /** @var Container $container */
41
        $container = $this->getContainer();
42
43
        $container->add('SLACK_WEBHOOK_URL', getenv('SLACK_WEBHOOK_URL'));
44
        $container->add('SLACK_CHANNEL', getenv('SLACK_CHANNEL'));
45
        $container->add('GITLAB_TOKEN', getenv('GITLAB_TOKEN'));
46
        $container->add('GITLAB_URL', (getenv('GITLAB_URL') ? getenv('GITLAB_URL') : 'https://gitlab.com'));
47
    }
48
}
49