Lines
100.00%
10 / 10
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| findSettledChange | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 4 | ||
| markApplied | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| 7 | final class SourceChangeTracker | |
| 8 | { | |
| 9 | private ?SourceFingerprint $pending = null; | |
| 10 | ||
| 11 | public function __construct(private SourceFingerprint $applied) {} | |
| 12 | ||
| 13 | // A change counts once two scans in a row agree on it, so a save that writes several files counts once. | |
| 14 | public function findSettledChange(SourceFingerprint $current): ?SourceFingerprint | |
| 15 | { | |
| 16 | if ($current->matches($this->applied)) { | |
| 17 | $this->pending = null; | |
| 18 | ||
| 19 | return null; | |
| 20 | } | |
| 21 | ||
| 22 | if ($this->pending === null || !$current->matches($this->pending)) { | |
| 23 | $this->pending = $current; | |
| 24 | ||
| 25 | return null; | |
| 26 | } | |
| 27 | ||
| 28 | return $current; | |
| 29 | } | |
| 30 | ||
| 31 | public function markApplied(SourceFingerprint $fingerprint): void | |
| 32 | { | |
| 33 | $this->applied = $fingerprint; | |
| 34 | $this->pending = null; | |
| 35 | } | |
| 36 | } |