Completed
Pull Request — master (#19)
by Tomas
04:33
created

SharedFileRestart::shouldRestart()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 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
    public function __construct($filePath)
12
    {
13
        $this->filePath = $filePath;
14
    }
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function shouldRestart(DateTime $startTime)
20
    {
21
        if (!file_exists($this->filePath)) {
22
            return false;
23
        }
24
25
        $time = filemtime($this->filePath);
26
        if ($time >= $startTime->getTimestamp()) {
27
            return true;
28
        }
29
30
        return false;
31
    }
32
}
33