Passed
Push — master ( 76636e...a7cce5 )
by Kevin
03:12
created

EnvironmentExtension::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Schedule\Extension;
4
5
/**
6
 * @author Kevin Bond <[email protected]>
7
 */
8
final class EnvironmentExtension
9
{
10
    private $runEnvironments;
11
12 4
    public function __construct(array $runEnvironments)
13
    {
14 4
        if (empty($runEnvironments)) {
15 1
            throw new \InvalidArgumentException('At least one environment must be configured.');
16
        }
17
18 3
        $this->runEnvironments = $runEnvironments;
19 3
    }
20
21
    public function __toString(): string
22
    {
23
        return \sprintf('Only run in [%s] environment%s', \implode(', ', $this->runEnvironments), \count($this->runEnvironments) > 1 ? 's' : '');
24
    }
25
26 3
    public function getRunEnvironments(): array
27
    {
28 3
        return $this->runEnvironments;
29
    }
30
}
31