ChmodOperation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Storeman\Operation;
4
5
use Storeman\FileReader;
6
use Storeman\VaultLayout\VaultLayoutInterface;
7
8 View Code Duplication
class ChmodOperation implements OperationInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $relativePath;
14
15
    /**
16
     * @var int
17
     */
18
    protected $mode;
19
20
    public function __construct(string $relativePath, int $mode)
21
    {
22
        $this->relativePath = $relativePath;
23
        $this->mode = $mode;
24
    }
25
26
    public function execute(string $localBasePath, FileReader $fileReader, VaultLayoutInterface $vaultLayout): bool
27
    {
28
        $absolutePath = $localBasePath . $this->relativePath;
29
30
        return chmod($absolutePath, $this->mode);
31
    }
32
33
    /**
34
     * @codeCoverageIgnore
35
     */
36
    public function __toString(): string
37
    {
38
        return sprintf('Chmod %s to %s', $this->relativePath, decoct($this->mode));
39
    }
40
}
41