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