LazyCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 1
A execute() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Lazy;
6
7
use Psr\Container\ContainerInterface;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface as Input;
10
use Symfony\Component\Console\Output\OutputInterface as Output;
11
12
final class LazyCommand extends Command
13
{
14
    /**
15
     * @var ContainerInterface
16
     */
17
    private $container;
18
19
    /**
20
     * @var string
21
     */
22
    private $serviceId;
23
24 2
    public function __construct(
25
        ContainerInterface $container,
26
        string $serviceId,
27
        string $name,
28
        array $definition = [],
29
        string $description = null,
30
        string $help = null
31
    ) {
32 2
        parent::__construct($name);
33
34 2
        $this->container = $container;
35 2
        $this->serviceId = $serviceId;
36
37 2
        $this->setDefinition($definition);
38 2
        $this->setDescription($description);
39 2
        $this->setHelp($help);
40 2
    }
41
42
    /**
43
     * @return int|null
44
     */
45 2
    protected function execute(Input $input, Output $output)
46
    {
47 2
        $command = $this->container->get($this->serviceId);
48
49 2
        return $command($input, $output);
50
    }
51
}
52