Passed
Push — main ( 70cc64...daf31f )
by Chema
01:00 queued 13s
created

BackendsConfig   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A jsonSerialize() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpLightning\Config;
6
7
use JsonSerializable;
8
use PhpLightning\Config\Backend\BackendConfigInterface;
9
10
final class BackendsConfig implements JsonSerializable
11
{
12
    /** @var list<BackendConfigInterface> */
0 ignored issues
show
Bug introduced by
The type PhpLightning\Config\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
    private array $configs = [];
14
15 1
    public function add(BackendConfigInterface $backendConfig): self
16
    {
17 1
        $this->configs[] = $backendConfig;
18 1
        return $this;
19
    }
20
21
    /**
22
     * @psalm-suppress MixedReturnTypeCoercion
23
     *
24
     * @return array<string,array>
25
     */
26 8
    public function jsonSerialize(): array
27
    {
28
        /**  @var array<string,array> $result */
29 8
        $result = [];
30
31 8
        foreach ($this->configs as $config) {
32
            /** @psalm-suppress MixedAssignment */
33 1
            $result[$config->getBackendName()] = $config->jsonSerialize();
34
        }
35
36 8
        return $result;
37
    }
38
}
39