Conditions | 7 |
Paths | 16 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | 2 | public static function gcd($number1) |
|
24 | { |
||
25 | 2 | $numbers = is_array($number1) ? $number1 : func_get_args(); |
|
26 | 2 | $n = min($numbers); |
|
27 | 2 | if (in_array(0, $numbers)) { |
|
28 | 1 | return max($numbers); |
|
29 | } |
||
30 | 2 | for ($i = $n; $i > 1; $i--) { |
|
31 | 2 | $isFind = true; |
|
32 | 2 | foreach ($numbers as $num) { |
|
33 | 2 | if (false === is_int($num / $i)) { |
|
34 | 2 | $isFind = false; |
|
35 | 2 | break; |
|
36 | } |
||
37 | } |
||
38 | 2 | if (true === $isFind) { |
|
39 | 2 | return $i; |
|
40 | } |
||
41 | } |
||
42 | 2 | return 1; |
|
43 | } |
||
45 |