Completed
Push — master ( 67926c...d2961a )
by Vladimir
03:11
created

ToolbeltServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 16
cts 16
cp 1
c 0
b 0
f 0
rs 10
wmc 2
lcom 0
cbo 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
commands() 0 1 ?
A register() 0 23 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Toolbelt;
6
7
use FondBot\Application\Kernel;
8
use Symfony\Component\Console\Application;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
abstract class ToolbeltServiceProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        'toolbelt',
15
    ];
16
17
    /**
18
     * Console commands.
19
     *
20
     * @return Command[]
21
     */
22
    abstract public function commands(): array;
23
24
    /**
25
     * Use the register method to register items with the container via the
26
     * protected $this->container property or the `getContainer` method
27
     * from the ContainerAwareTrait.
28
     *
29
     * @return void
30
     *
31
     * @throws \Psr\Container\ContainerExceptionInterface
32
     */
33
    public function register(): void
34
    {
35 1
        $this->container->share('toolbelt', function () {
36 1
            $kernel = $this->container->get(Kernel::class);
37
38 1
            $application = new Application('FondBot', Kernel::VERSION);
39 1
            $application->addCommands([
40 1
                new Commands\MakeIntent($kernel),
41 1
                new Commands\MakeInteraction($kernel),
42 1
                new Commands\ListDrivers($kernel),
43 1
                new Commands\InstallDriver($kernel),
44 1
                new Commands\ListChannels($kernel),
45 1
                new Commands\Log($kernel),
46 1
                new Commands\QueueWorker($kernel),
47
            ]);
48
49 1
            foreach ($this->commands() as $command) {
50 1
                $application->add($command);
51
            }
52
53 1
            return $application;
54 1
        });
55 1
    }
56
}
57