| Total Complexity | 11 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class LastTime |
||
| 13 | { |
||
| 14 | protected $filePath; |
||
| 15 | |||
| 16 | public function __construct(string $filePath) |
||
| 19 | } |
||
| 20 | |||
| 21 | public function wasRunSince(DateInterval $interval): bool |
||
| 22 | { |
||
| 23 | $previous = $this->get(); |
||
| 24 | |||
| 25 | if (false === $previous || $previous->add($interval) < new DateTime('now')) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | |||
| 29 | return true; |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Return false if never runned else last datetime it was runned. |
||
| 34 | * If $default is set, return $default time if never runned. |
||
| 35 | */ |
||
| 36 | public function get($default = false) |
||
| 43 | } |
||
| 44 | |||
| 45 | public function setWasRun($datetime = 'now', $setIfNotExist = true): void |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * alias for set was run. |
||
| 59 | */ |
||
| 60 | public function set($datetime = 'now') |
||
| 63 | } |
||
| 64 | } |
||
| 65 |