Passed
Push — master ( 4d5f71...6b73cf )
by Kevin
02:12
created

EnvironmentExtension::__toString()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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