Completed
Pull Request — master (#250)
by
unknown
20:15
created

YamlFileCollection::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Liip\MonitorBundle\Check;
6
7
use Laminas\Diagnostics\Check\CheckCollectionInterface;
8
use Laminas\Diagnostics\Check\CheckInterface;
9
10 View Code Duplication
class YamlFileCollection implements CheckCollectionInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * @var CheckInterface[]
14
     */
15
    private $checks = [];
16
17
    public function __construct(array $configs)
18
    {
19
        foreach ($configs as $config) {
20
            $path = $config['path'];
21
22
            $check = new YamlFile($path);
23
24
            $label = $config['label'] ?? sprintf('YAML file `%s` exists and valid', $path);
25
            $check->setLabel($label);
26
27
            $this->checks[sprintf('file_yaml_%s', $path)] = $check;
28
        }
29
    }
30
31
    /**
32
     * @return CheckInterface[]
33
     */
34
    public function getChecks(): array
35
    {
36
        return $this->checks;
37
    }
38
}
39