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

SharedFileRestart::shouldRestart()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 3
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