SuffixTypesBuilder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 72
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addConfig() 0 5 1
A build() 0 7 1
A addFacade() 0 5 1
A addFactory() 0 5 1
A addProvider() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\Config\GacelaConfigBuilder;
6
7
final class SuffixTypesBuilder
8
{
9
    public const DEFAULT_SUFFIX_TYPES = [
10
        'Facade' => self::DEFAULT_FACADES,
11
        'Factory' => self::DEFAULT_FACTORIES,
12
        'Config' => self::DEFAULT_CONFIGS,
13
        'Provider' => self::DEFAULT_PROVIDERS,
14
    ];
15
16
    private const DEFAULT_FACADES = ['Facade'];
17
18
    private const DEFAULT_FACTORIES = ['Factory'];
19
20
    private const DEFAULT_CONFIGS = ['Config'];
21
22
    private const DEFAULT_PROVIDERS = ['Provider'];
23
24
    /** @var list<string> */
25
    private array $facades = self::DEFAULT_FACADES;
26
27
    /** @var list<string> */
28
    private array $factories = self::DEFAULT_FACTORIES;
29
30
    /** @var list<string> */
31
    private array $configs = self::DEFAULT_CONFIGS;
32
33 6
    /** @var list<string> */
34
    private array $providers = self::DEFAULT_PROVIDERS;
35 6
36
    public function addFacade(string $suffix): self
37 6
    {
38
        $this->facades[] = $suffix;
39
40 6
        return $this;
41
    }
42 6
43
    public function addFactory(string $suffix): self
44 6
    {
45
        $this->factories[] = $suffix;
46
47 6
        return $this;
48
    }
49 6
50
    public function addConfig(string $suffix): self
51 6
    {
52
        $this->configs[] = $suffix;
53
54 8
        return $this;
55
    }
56 8
57
    public function addProvider(string $suffix): self
58 8
    {
59
        $this->providers[] = $suffix;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @return array{
66
     *     Facade: list<string>,
67
     *     Factory: list<string>,
68
     *     Config: list<string>,
69 75
     *     Provider: list<string>,
70
     * }
71 75
     */
72 75
    public function build(): array
73 75
    {
74 75
        return [
75 75
            'Facade' => array_values(array_unique($this->facades)),
76 75
            'Factory' => array_values(array_unique($this->factories)),
77
            'Config' => array_values(array_unique($this->configs)),
78
            'Provider' => array_values(array_unique($this->providers)),
79
        ];
80
    }
81
}
82