Passed
Pull Request — master (#323)
by Fabien
02:12
created

ParallelJobs::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Configuration\Validator;
6
7
use Churn\Configuration\Config;
8
use Churn\Configuration\Validator;
9
use Webmozart\Assert\Assert;
10
11
/**
12
 * @internal
13
 */
14
final class ParallelJobs implements Validator
15
{
16
    private const KEY = 'parallelJobs';
17
18
    /**
19
     * Returns the configuration key.
20
     */
21
    public function getKey(): string
22
    {
23
        return self::KEY;
24
    }
25
26
    /**
27
     * @param Config $config The configuration object.
28
     * @param array<mixed> $configuration The array containing the configuration values.
29
     */
30
    public function validate(Config $config, array $configuration): void
31
    {
32
        if (!\array_key_exists(self::KEY, $configuration)) {
33
            return;
34
        }
35
36
        $value = $configuration[self::KEY];
37
38
        Assert::integer($value, 'Amount of parallel jobs should be an integer');
39
40
        $config->setParallelJobs($value);
41
    }
42
}
43