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

addTemplateByFilenameMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 7
rs 10
ccs 6
cts 6
cp 1
cc 1
nc 1
nop 1
crap 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