Passed
Push — master ( c4863b...3c709b )
by Jesús
03:18 queued 12s
created

GacelaConfigFile::getCustomServicesLocation()   A

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 Gacela\Framework\Config\GacelaFileConfig;
6
7
use Gacela\Framework\Config\ConfigReader\PhpConfigReader;
8
use Gacela\Framework\Config\ConfigReaderInterface;
9
10
final class GacelaConfigFile
11
{
12
    /** @var list<GacelaConfigItem> */
13
    private array $configItems = [];
14
15
    /** @var array<class-string,class-string|callable> */
16
    private array $mappingInterfaces = [];
17
18
    /** @var array<string,ConfigReaderInterface> */
19
    private array $configReaders = [];
20
21
    /** @var list<string> Namespaces relative to a module */
22
    private array $customServicesLocation = [];
23
24 30
    public static function withDefaults(): self
25
    {
26 30
        return (new self())
27 30
            ->setConfigItems([GacelaConfigItem::withDefaults()])
28 30
            ->setConfigReaders(['php' => new PhpConfigReader()]);
29
    }
30
31
    /**
32
     * @param list<GacelaConfigItem> $configItems
33
     */
34 32
    public function setConfigItems(array $configItems): self
35
    {
36 32
        $this->configItems = $configItems;
0 ignored issues
show
Documentation Bug introduced by
It seems like $configItems of type array is incompatible with the declared type Gacela\Framework\Config\GacelaFileConfig\list of property $configItems.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
38 32
        return $this;
39
    }
40
41
    /**
42
     * @return list<GacelaConfigItem>
43
     */
44 32
    public function getConfigItems(): array
45
    {
46 32
        return $this->configItems;
1 ignored issue
show
Bug Best Practice introduced by
The expression return $this->configItems returns the type array which is incompatible with the documented return type Gacela\Framework\Config\GacelaFileConfig\list.
Loading history...
47
    }
48
49
    /**
50
     * @param array<string,ConfigReaderInterface> $configReaders
51
     */
52 32
    public function setConfigReaders(array $configReaders): self
53
    {
54 32
        $this->configReaders = $configReaders;
55
56 32
        return $this;
57
    }
58
59
    /**
60
     * @return array<string,ConfigReaderInterface>
61
     */
62 32
    public function getConfigReaders(): array
63
    {
64 32
        return $this->configReaders;
65
    }
66
67
    /**
68
     * @param array<class-string,class-string|callable> $mappingInterfaces
69
     */
70 6
    public function setMappingInterfaces(array $mappingInterfaces): self
71
    {
72 6
        $this->mappingInterfaces = $mappingInterfaces;
73
74 6
        return $this;
75
    }
76
77
    /**
78
     * Map interfaces to concrete classes or callable (which will be resolved on runtime).
79
     * This is util to inject dependencies to Gacela services (such as Factories, for example) via their constructor.
80
     *
81
     * @return mixed
82
     */
83 2
    public function getMappingInterface(string $key)
84
    {
85 2
        return $this->mappingInterfaces[$key] ?? null;
86
    }
87
88
    /**
89
     * @param list<string> $customServicesLocation
90
     */
91 3
    public function setCustomServicesLocation(array $customServicesLocation): self
92
    {
93 3
        $this->customServicesLocation = $customServicesLocation;
0 ignored issues
show
Documentation Bug introduced by
It seems like $customServicesLocation of type array is incompatible with the declared type Gacela\Framework\Config\GacelaFileConfig\list of property $customServicesLocation.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
94
95 3
        return $this;
96
    }
97
98
    /**
99
     * @return list<string>
100
     */
101 18
    public function getCustomServicesLocation(): array
102
    {
103 18
        return $this->customServicesLocation;
1 ignored issue
show
Bug Best Practice introduced by
The expression return $this->customServicesLocation returns the type array which is incompatible with the documented return type Gacela\Framework\Config\GacelaFileConfig\list.
Loading history...
104
    }
105
}
106