Conditions | 9 |
Paths | 7 |
Total Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Tests | 21 |
CRAP Score | 9.576 |
Changes | 0 |
1 | <?php |
||
22 | 54 | public static function get_array($geometry) { |
|
23 | 54 | self::init_db(); |
|
24 | 54 | $count = count($geometry); |
|
25 | 54 | if (!isset(self::$_db[$count])) { |
|
26 | return null; |
||
27 | } |
||
28 | |||
29 | 54 | $hash = implode('-', $geometry); |
|
30 | 54 | if (!isset(self::$_db[$count][$hash])) { |
|
31 | return null; |
||
32 | } |
||
33 | |||
34 | 54 | $indexes = explode(',', self::$_db[$count][$hash]); |
|
35 | 54 | $pairs = []; |
|
36 | 54 | foreach ($indexes as $s) { |
|
37 | 54 | $value = []; |
|
38 | 54 | while (!empty($s)) { |
|
39 | 54 | $c = substr($s, 0, 1); |
|
40 | 54 | $s = substr($s, 1); |
|
41 | 54 | $ord = ord($c); |
|
42 | 54 | if (($ord >= ord('a')) and ($ord <= ord('z'))) { |
|
43 | 54 | $value[] = $ord - ord('a'); |
|
44 | 18 | } elseif (($ord >= ord('A')) and ($ord <= ord('Z'))) { |
|
45 | $value[] = $ord - ord('A') + 26; |
||
46 | } else { |
||
47 | throw new OrthogonalArraysException(); |
||
48 | } |
||
49 | 18 | } |
|
50 | 54 | $pairs[] = $value; |
|
51 | 18 | } |
|
52 | |||
53 | 54 | return $pairs; |
|
54 | } |
||
55 | |||
58 | ?> |