Passed
Push — 1.0 ( 1757a3...241f9e )
by Vladimir
02:41
created

ChannelServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 29
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Channels\Providers;
6
7
use FondBot\Application\Config;
8
use FondBot\Channels\ChannelManager;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
class ChannelServiceProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        ChannelManager::class,
15
    ];
16
17
    /**
18
     * Use the register method to register items with the container via the
19
     * protected $this->container property or the `getContainer` method
20
     * from the ContainerAwareTrait.
21
     *
22
     * @return void
23
     */
24
    public function register(): void
25
    {
26
        /** @var Config $config */
27
        $config = $this->getContainer()->get(Config::class);
28
        /** @var array $channels */
29
        $channels = $config->get('channels', []);
30
31
        $manager = new ChannelManager;
32
33
        foreach ($channels as $name => $parameters) {
34
            $manager->add($name, $parameters);
35
        }
36
37
        $this->getContainer()->add(ChannelManager::class, $manager);
38
    }
39
}
40