| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | abstract class FileLinesMetric implements Metric |
||
| 10 | { |
||
| 11 | protected string $filename = ''; |
||
| 12 | protected string $name = ''; |
||
| 13 | |||
| 14 | public function getName(): string |
||
| 17 | } |
||
| 18 | |||
| 19 | public function isApplicable(): bool |
||
| 22 | } |
||
| 23 | |||
| 24 | public function getValue(float $lastValue): float |
||
| 25 | { |
||
| 26 | $lastLineCount = Memory::getInstance()->getLastData($this->getName() . '_absolute', -1); |
||
| 27 | $lineCount = $this->getLineCount($this->filename); |
||
| 28 | Memory::getInstance()->addData($this->getName() . '_absolute', $lineCount); |
||
| 29 | |||
| 30 | // this is the first run we return 0 to skip this value |
||
| 31 | if ($lastLineCount < 0) { |
||
| 32 | return 0; |
||
| 33 | } |
||
| 34 | |||
| 35 | // we assume that there was a log rotation done here |
||
| 36 | if ($lineCount < $lastLineCount) { |
||
| 37 | return $lineCount; |
||
| 38 | } |
||
| 39 | |||
| 40 | return $lineCount - $lastLineCount; |
||
| 41 | } |
||
| 42 | |||
| 43 | protected function getLineCount($path): int |
||
| 47 | } |
||
| 48 | } |