| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 76 | public function getFrequencyReachedTwice(int $frequency = 0): int |
||
| 77 | { |
||
| 78 | $memory = [$frequency => 1]; |
||
| 79 | |||
| 80 | $found = false; |
||
| 81 | while (!$found) { |
||
| 82 | foreach ($this->changes as $change) { |
||
| 83 | $frequency += $change; |
||
| 84 | |||
| 85 | if (isset($memory[$frequency])) { |
||
| 86 | $found = true; |
||
| 87 | break; |
||
| 88 | } |
||
| 89 | |||
| 90 | $memory[$frequency] = 1; |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | return $frequency; |
||
| 95 | } |
||
| 97 |