Passed
Pull Request — main (#5)
by Chema
02:17
created

BackendsConfig::jsonSerialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 6
rs 10
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
    public function add(BackendConfigInterface $backendConfig): self
16
    {
17
        $this->configs[] = $backendConfig;
18
        return $this;
19
    }
20
21
    public function jsonSerialize(): array
22
    {
23
        $result = [];
24
25
        foreach ($this->configs as $config) {
26
            $result[$config->getBackendName()] = $config->jsonSerialize();
27
        }
28
29
        return $result;
30
    }
31
}
32