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

SharedFileRestart   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 0
dl 0
loc 26
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A shouldRestart() 0 13 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