Completed
Push — master ( 31759b...1ab698 )
by Tomas
9s
created

SharedFileRestart::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Tomaj\Hermes\Restart;
4
5
use DateTime;
6
7
class SharedFileRestart implements RestartInterface
8
{
9
    private $filePath;
10
11 9
    public function __construct($filePath)
12
    {
13 9
        $this->filePath = $filePath;
14 9
    }
15
16
    /**
17
     * {@inheritdoc}
18
     */
19 9
    public function shouldRestart(DateTime $startTime)
20
    {
21 9
        if (!file_exists($this->filePath)) {
22 3
            return false;
23
        }
24
25 6
        $time = filemtime($this->filePath);
26 6
        if ($time >= $startTime->getTimestamp()) {
27 3
            return true;
28
        }
29
30 3
        return false;
31
    }
32
}
33