Completed
Push — master ( b350e3...8d2c4d )
by Arne
01:49
created

TouchOperation::getAbsolutePath()   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
class TouchOperation implements OperationInterface
6
{
7
    protected $absolutePath;
8
    protected $mtime;
9
10
    public function __construct(string $absolutePath, int $mtime)
11
    {
12
        $this->absolutePath = $absolutePath;
13
        $this->mtime = $mtime;
14
    }
15
16
    public function getAbsolutePath(): string
17
    {
18
        return $this->absolutePath;
19
    }
20
21
    public function getMtime(): int
22
    {
23
        return $this->mtime;
24
    }
25
26
    public function execute(): bool
27
    {
28
        return touch($this->absolutePath, $this->mtime);
29
    }
30
31
    /**
32
     * @codeCoverageIgnore
33
     */
34
    public function __toString(): string
35
    {
36
        return sprintf('Touch %s to mtime = %s', $this->absolutePath, date('c', $this->mtime));
37
    }
38
}
39