Passed
Push — feature/refactor-code-generato... ( fb1bf5 )
by Chema
04:20
created

ConsoleDependencyProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
c 0
b 0
f 0
dl 0
loc 27
rs 10
ccs 11
cts 13
cp 0.8462

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addCommands() 0 5 1
A provideModuleDependencies() 0 4 1
A addTemplateByFilenameMap() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console;
6
7
use Gacela\Console\Domain\FilenameSanitizer\FilenameSanitizer;
8
use Gacela\Console\Infrastructure\Command\MakeFileCommand;
9
use Gacela\Console\Infrastructure\Command\MakeModuleCommand;
10
use Gacela\Framework\AbstractDependencyProvider;
11
use Gacela\Framework\Container\Container;
12
13
/**
14
 * @method ConsoleConfig getConfig()
15
 */
16
final class ConsoleDependencyProvider extends AbstractDependencyProvider
17
{
18
    public const COMMANDS = 'COMMANDS';
19
20
    public const TEMPLATE_BY_FILENAME_MAP = 'TEMPLATE_FILENAME_MAP';
21
22 1
    public function provideModuleDependencies(Container $container): void
23
    {
24 1
        $this->addCommands($container);
25 1
        $this->addTemplateByFilenameMap($container);
26
    }
27
28 1
    private function addCommands(Container $container): void
29
    {
30 1
        $container->set(self::COMMANDS, static fn () => [
31
            new MakeFileCommand(),
32
            new MakeModuleCommand(),
33
        ]);
34
    }
35
36 1
    private function addTemplateByFilenameMap(Container $container): void
37
    {
38 1
        $container->set(self::TEMPLATE_BY_FILENAME_MAP, fn () => [
39 1
            FilenameSanitizer::FACADE => $this->getConfig()->getFacadeMakerTemplate(),
40 1
            FilenameSanitizer::FACTORY => $this->getConfig()->getFactoryMakerTemplate(),
41 1
            FilenameSanitizer::CONFIG => $this->getConfig()->getConfigMakerTemplate(),
42 1
            FilenameSanitizer::DEPENDENCY_PROVIDER => $this->getConfig()->getDependencyProviderMakerTemplate(),
43
        ]);
44
    }
45
}
46