Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
45 | public static function sumOfSquares(array $numbers): float |
||
46 | { |
||
47 | if (empty($numbers)) { |
||
48 | throw InvalidArgumentException::arrayCantBeEmpty(); |
||
49 | } |
||
50 | |||
51 | $mean = Mean::arithmetic($numbers); |
||
52 | |||
53 | return array_sum(array_map( |
||
54 | function ($val) use ($mean) { |
||
55 | return ($val - $mean) ** 2; |
||
56 | }, |
||
57 | $numbers |
||
58 | )); |
||
59 | } |
||
60 | } |
||
61 |