Conditions | 1 |
Paths | 1 |
Total Lines | 8 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
45 | 2 | public function addScore(string $name, int $score): void |
|
46 | { |
||
47 | 2 | $scores = $this->getHighscores(); |
|
48 | 2 | $scores[] = ['name' => $name, 'score' => $score]; |
|
49 | 2 | usort($scores, fn ($a, $b) => $b['score'] <=> $a['score']); |
|
50 | 2 | $scores = array_slice($scores, 0, 10); |
|
51 | |||
52 | 2 | file_put_contents($this->file, json_encode($scores, JSON_PRETTY_PRINT)); |
|
53 | } |
||
55 |