Completed
Push — master ( 356849...08f0e0 )
by Changwan
05:29
created

ConsoleServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 14 2
A boot() 0 3 1
1
<?php
2
namespace Wandu\Console;
3
4
use Symfony\Component\Console\Application as SymfonyApplication;
5
use Wandu\DI\ContainerInterface;
6
use Wandu\DI\ServiceProviderInterface;
7
use Wandu\Foundation\Application;
8
9
class ConsoleServiceProvider implements ServiceProviderInterface 
10
{
11
    /** @var array */
12
    protected $commands = [];
13
    
14
    public function register(ContainerInterface $app)
15
    {
16
        $app->closure(SymfonyApplication::class, function () {
17
            return new SymfonyApplication(
18
                Application::NAME,
19
                Application::VERSION
20
            );
21
        });
22
        $app->bind(Dispatcher::class)->after(function (Dispatcher $dispatcher) {
23
            foreach ($this->commands as $name => $command) {
24
                $dispatcher->add($name, $command);
25
            }
26
        });
27
    }
28
29
    public function boot(ContainerInterface $app)
30
    {
31
    }
32
}
33