SymlinkOperation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A execute() 0 7 1
A __toString() 0 4 1
1
<?php
2
3
namespace Storeman\Operation;
4
5
use Storeman\FileReader;
6
use Storeman\VaultLayout\VaultLayoutInterface;
7
8
class SymlinkOperation implements OperationInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $relativePath;
14
15
    /**
16
     * @var string
17
     */
18
    protected $relativeLinkTarget;
19
20
    public function __construct(string $relativePath, string $relativeLinkTarget)
21
    {
22
        $this->relativePath = $relativePath;
23
        $this->relativeLinkTarget = $relativeLinkTarget;
24
    }
25
26
    public function execute(string $localBasePath, FileReader $fileReader, VaultLayoutInterface $vaultLayout): bool
27
    {
28
        $absolutePath = $localBasePath . $this->relativePath;
29
        $absoluteLinkTarget = $localBasePath . $this->relativeLinkTarget;
30
31
        return symlink($absoluteLinkTarget, $absolutePath);
32
    }
33
34
    /**
35
     * @codeCoverageIgnore
36
     */
37
    public function __toString(): string
38
    {
39
        return sprintf('Symlink %s to %s', $this->relativePath, $this->relativeLinkTarget);
40
    }
41
}
42