Test Failed
Push — feature/gacela-config-callable ( f0c396 )
by Chema
04:24
created

GacelaConfig::mapInterface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Setup;
6
7
use Gacela\Framework\Config\ConfigReaderInterface;
8
use Gacela\Framework\Config\GacelaConfigBuilder\ConfigBuilder;
9
use Gacela\Framework\Config\GacelaConfigBuilder\MappingInterfacesBuilder;
10
use Gacela\Framework\Config\GacelaConfigBuilder\SuffixTypesBuilder;
11
12
final class GacelaConfig
13
{
14
    private ConfigBuilder $configBuilder;
15
    private SuffixTypesBuilder $suffixTypesBuilder;
16
    private MappingInterfacesBuilder $mappingInterfacesBuilder;
17
18
    public function __construct()
19
    {
20
        $this->configBuilder = new ConfigBuilder();
21
        $this->suffixTypesBuilder = new SuffixTypesBuilder();
22
        $this->mappingInterfacesBuilder = new MappingInterfacesBuilder();
23
    }
24
25
    public function getConfigBuilder(): ConfigBuilder
26
    {
27
        return $this->configBuilder;
28
    }
29
30
    public function getSuffixTypesBuilder(): SuffixTypesBuilder
31
    {
32
        return $this->suffixTypesBuilder;
33
    }
34
35
    public function getMappingInterfacesBuilder(): MappingInterfacesBuilder
36
    {
37
        return $this->mappingInterfacesBuilder;
38
    }
39
40
    /**
41
     * @param string $path define the path where Gacela will read all the config files
42
     * @param string $pathLocal define the path where Gacela will read the local config file
43
     * @param class-string<ConfigReaderInterface>|ConfigReaderInterface|null $reader Define the reader class which will read and parse the config files
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<ConfigReade...figReaderInterface|null at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<ConfigReaderInterface>|ConfigReaderInterface|null.
Loading history...
44
     */
45
    public function addAppConfig(string $path, string $pathLocal = '', $reader = null): self
46
    {
47
        $this->configBuilder->add($path, $pathLocal, $reader);
48
49
        return $this;
50
    }
51
52
    public function addSuffixTypeFacade(string $suffix): self
53
    {
54
        $this->suffixTypesBuilder->addFacade($suffix);
55
56
        return $this;
57
    }
58
59
    public function addSuffixTypeFactory(string $suffix): self
60
    {
61
        $this->suffixTypesBuilder->addFactory($suffix);
62
63
        return $this;
64
    }
65
66
    public function addSuffixTypeConfig(string $suffix): self
67
    {
68
        $this->suffixTypesBuilder->addConfig($suffix);
69
70
        return $this;
71
    }
72
73
    public function addSuffixTypeDependencyProvider(string $suffix): self
74
    {
75
        $this->suffixTypesBuilder->addDependencyProvider($suffix);
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param class-string $key
1 ignored issue
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
82
     * @param class-string|object|callable $value
83
     */
84
    public function mapInterface(string $key, $value): self
85
    {
86
        $this->mappingInterfacesBuilder->bind($key, $value);
87
88
        return $this;
89
    }
90
}
91