ChangeWorkingDirectoryStep::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zalas\Symfify\Composer\SymfifyStep;
6
7
use Zalas\Symfify\Composer\SymfifyStep;
8
9
class ChangeWorkingDirectoryStep implements SymfifyStep
10
{
11
    /**
12
     * @var string
13
     */
14
    private $path;
15
16
    /**
17
     * @param string $path
18
     */
19 5
    public function __construct($path)
20
    {
21 5
        $this->path = $path;
22
    }
23
24 4
    public function __invoke()
25
    {
26 4
        if (!\is_dir($this->path) || !\chdir($this->path)) {
27 2
            throw new \InvalidArgumentException(\sprintf('The given directory path does not exist: "%s".', $this->path));
28
        }
29
    }
30
}
31