Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 5 | public function compileOrderByPath() |
|
18 | 5 | { |
|
19 | $column = $this->model->getLocalKeyName(); |
||
20 | 5 | ||
21 | $path = $this->wrap( |
||
22 | 5 | $this->model->getPathName() |
|
23 | 1 | ); |
|
24 | |||
25 | $pathSeparator = $this->model->getPathSeparator(); |
||
26 | 4 | ||
27 | 4 | if (!$this->model->isIntegerAttribute($column)) { |
|
28 | return "$path asc"; |
||
29 | 4 | } |
|
30 | 4 | ||
31 | return <<<SQL |
||
32 | regexp_replace( |
||
33 | 4 | regexp_replace( |
|
34 | $path, |
||
35 | '(^|[$pathSeparator])(\\\\d+)', |
||
36 | 4 | '\\\\100000000000000000000\\\\2' |
|
37 | ), |
||
38 | '0+(\\\\d\{20\})([$pathSeparator]|$)', |
||
39 | '\\\\1\\\\2' |
||
44 |