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

SharedFileRestart   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

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
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
    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