Completed
Push — master ( b31514...603a9f )
by Changwan
06:16
created

Bootstrap::providers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 0
cts 7
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Foundation\ConsoleApp;
3
4
use Wandu\Config\ConfigServiceProvider;
5
use Wandu\Config\Contracts\Config;
6
use Wandu\Console\ConsoleServiceProvider;
7
use Wandu\Console\Contracts\CommandAttachable;
8
use Wandu\Console\Dispatcher;
9
use Wandu\DI\ContainerInterface;
10
use Wandu\Foundation\Contracts\Bootstrap as BootstrapAbstract;
11
12
abstract class Bootstrap implements BootstrapAbstract
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function providers(): array
18
    {
19
        return [
20
            new ConfigServiceProvider(),
21
            new ConsoleServiceProvider(),
22
        ];
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function boot(ContainerInterface $app)
29
    {
30
        $this->registerConfiguration($app->get(Config::class));
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function execute(ContainerInterface $app): int
37
    {
38
        $dispatcher = $app->get(Dispatcher::class);
39
        $this->registerCommands($dispatcher);
40
        return $dispatcher->execute();
41
    }
42
43
    /**
44
     * @param \Wandu\Console\Contracts\CommandAttachable $manager
45
     */
46
    abstract public function registerCommands(CommandAttachable $manager);
47
48
    /**
49
     * @param \Wandu\Config\Contracts\Config $config
50
     */
51
    abstract public function registerConfiguration(Config $config);
52
}
53