| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | abstract class FileLinesMetric implements Metric |
||
| 9 | { |
||
| 10 | protected string $filename = ''; |
||
| 11 | protected string $name = ''; |
||
| 12 | |||
| 13 | public function getName(): string |
||
| 14 | { |
||
| 15 | return $this->name; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function isApplicable(): bool |
||
| 19 | { |
||
| 20 | return File::getInstance()->fileExists($this->filename); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function getValue(float $lastValue): float |
||
| 24 | { |
||
| 25 | $lineCount = $this->getLineCount($this->filename); |
||
| 26 | |||
| 27 | // we assume that there was a log rotation done here |
||
| 28 | if ($lineCount < $lastValue) { |
||
| 29 | return $lineCount; |
||
| 30 | } |
||
| 31 | |||
| 32 | return $lineCount - $lastValue; |
||
| 33 | } |
||
| 34 | |||
| 35 | protected function getLineCount($path): int |
||
| 39 | } |
||
| 40 | } |