Application::container()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\RfcLinc\Application\Cli;
6
7
use PhpCfdi\RfcLinc\Application\Cli\Commands\CatalogCommand;
8
use PhpCfdi\RfcLinc\Application\Cli\Commands\UpdateCommand;
9
use PhpCfdi\RfcLinc\Application\SetUpContainerTrait;
10
use Pimple\Container;
11
use Symfony\Component\Console\Application as ConsoleApplication;
12
13
class Application extends ConsoleApplication
14
{
15
    use SetUpContainerTrait;
16
17
    /** @var Container */
18
    private $container;
19
20 5
    public function __construct(Container $container)
21
    {
22 5
        parent::__construct('rfclinc', '0.1.0');
23 5
        $this->container = $container;
24 5
    }
25
26 5
    public function container(): Container
27
    {
28 5
        return $this->container;
29
    }
30
31 5
    public static function createApplication(): self
32
    {
33
        // create
34 5
        $containter = new Container();
35 5
        $app = new static($containter);
36
37 5
        static::setUpContainer($containter);
38
39
        // pass container to avoid gateway creation
40 5
        $app->add(new UpdateCommand($containter));
41 5
        $app->add(new CatalogCommand($containter));
42
43 5
        return $app;
44
    }
45
}
46