Completed
Push — 1.0 ( 678007...4c5066 )
by Vladimir
21:50
created

ChannelServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 29
ccs 8
cts 8
cp 1
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;
6
7
use FondBot\Application\Config;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
10
class ChannelServiceProvider extends AbstractServiceProvider
11
{
12
    protected $provides = [
13
        ChannelManager::class,
14
    ];
15
16
    /**
17
     * Use the register method to register items with the container via the
18
     * protected $this->container property or the `getContainer` method
19
     * from the ContainerAwareTrait.
20
     *
21
     * @return void
22
     */
23 1
    public function register(): void
24
    {
25
        /** @var Config $config */
26 1
        $config = $this->getContainer()->get(Config::class);
27
        /** @var array $channels */
28 1
        $channels = $config->get('channels', []);
29
30 1
        $manager = new ChannelManager;
31
32 1
        foreach ($channels as $name => $parameters) {
33 1
            $manager->add($name, $parameters);
34
        }
35
36 1
        $this->getContainer()->add(ChannelManager::class, $manager);
37 1
    }
38
}
39