EnvironmentExtension   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 28
ccs 7
cts 9
cp 0.7778
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 3 2
A __construct() 0 7 2
A getRunEnvironments() 0 3 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Schedule\Extension;
4
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
final class EnvironmentExtension
9
{
10
    /** @var string[] */
11
    private $runEnvironments;
12 4
13
    /**
14 4
     * @param string[] $runEnvironments
15 1
     */
16
    public function __construct(array $runEnvironments)
17
    {
18 3
        if (empty($runEnvironments)) {
19 3
            throw new \InvalidArgumentException('At least one environment must be configured.');
20
        }
21
22
        $this->runEnvironments = $runEnvironments;
23
    }
24
25
    public function __toString(): string
26 3
    {
27
        return \sprintf('Only run in [%s] environment%s', \implode(', ', $this->runEnvironments), \count($this->runEnvironments) > 1 ? 's' : '');
28 3
    }
29
30
    /**
31
     * @return string[]
32
     */
33
    public function getRunEnvironments(): array
34
    {
35
        return $this->runEnvironments;
36
    }
37
}
38