Conditions | 5 |
Paths | 6 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
13 | 1 | public function compare($a, $b) { |
|
14 | // find first difference |
||
15 | 1 | $cmp1 = null; |
|
16 | 1 | $cmp2 = null; |
|
17 | 1 | $min = min(strlen($a), strlen($b)); |
|
18 | 1 | for ($i = 0; $i < $min; $i++) { |
|
19 | 1 | if ($a[$i] != $b[$i]) { |
|
20 | 1 | $cmp1 = $a[$i]; |
|
21 | 1 | $cmp2 = $b[$i]; |
|
22 | 1 | break; |
|
23 | } |
||
24 | } |
||
25 | |||
26 | 1 | if ($cmp1 === null && $cmp2 === null) { |
|
27 | 1 | return 0; |
|
28 | } |
||
29 | |||
30 | 1 | return $this->getAscii($cmp1) - $this->getAscii($cmp2); |
|
31 | } |
||
32 | |||
43 | } |