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

Bootstrap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

5 Methods

Rating   Name   Duplication   Size   Complexity  
A providers() 0 7 1
A boot() 0 4 1
A execute() 0 6 1
registerCommands() 0 1 ?
registerConfiguration() 0 1 ?
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