ChmodOperation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 33
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A execute() 6 6 1
A __toString() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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