Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
2 / 4
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
FileTime
50.00% covered (danger)
50.00%
2 / 4
0.00% covered (danger)
0.00%
0 / 2
4.12
0.00% covered (danger)
0.00%
0 / 1
 setup
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 modification
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
1<?php
2/** @noinspection PhpUnhandledExceptionInspection */
3declare(strict_types=1);
4// TODO unit test
5
6class FileTime {
7  private static ?int $staticModificationTime;
8
9  static public function setup(?int $staticModificationTime): void {
10    self::$staticModificationTime = $staticModificationTime;
11  }
12
13  static function modification(string $filePath): int {
14    if (!file_exists($filePath)) {
15      throw new Error("File not found: `$filePath`");
16    }
17    return self::$staticModificationTime ?? filemtime($filePath);
18  }
19}