Completed
Push — master ( 77f170...166d1e )
by Arne
03:02
created

TouchOperation::getMtime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Archivr\Operation;
4
5
use Archivr\ConnectionAdapter\ConnectionAdapterInterface;
6
7
class TouchOperation implements OperationInterface
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $relativePath;
13
14
    /**
15
     * @var int
16
     */
17
    protected $mtime;
18
19
    public function __construct(string $relativePath, int $mtime)
20
    {
21
        $this->relativePath = $relativePath;
22
        $this->mtime = $mtime;
23
    }
24
25
    public function getRelativePath(): string
26
    {
27
        return $this->relativePath;
28
    }
29
30
    public function getMtime(): int
31
    {
32
        return $this->mtime;
33
    }
34
35
    public function execute(string $localBasePath, ConnectionAdapterInterface $connection): bool
36
    {
37
        $absolutePath = $localBasePath . $this->relativePath;
38
39
        return touch($absolutePath, $this->mtime);
40
    }
41
42
    /**
43
     * @codeCoverageIgnore
44
     */
45
    public function __toString(): string
46
    {
47
        return sprintf('Touch %s to mtime = %s', $this->relativePath, date('c', $this->mtime));
48
    }
49
}
50