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 |
||
12 | 4 | public function compileOrderByPath() |
|
13 | { |
||
14 | 4 | $column = $this->model->getLocalKeyName(); |
|
15 | |||
16 | 4 | $path = $this->wrap( |
|
17 | 4 | $this->model->getPathName() |
|
18 | ); |
||
19 | |||
20 | 4 | $pathSeparator = $this->model->getPathSeparator(); |
|
21 | |||
22 | 4 | if (!$this->model->isIntegerAttribute($column)) { |
|
23 | 1 | return "$path asc"; |
|
24 | } |
||
25 | |||
26 | return <<<SQL |
||
27 | 3 | regexp_replace( |
|
28 | regexp_replace( |
||
29 | 3 | $path, |
|
30 | 3 | '(^|[$pathSeparator])(\\\\d+)', |
|
31 | '\\\\100000000000000000000\\\\2' |
||
32 | ), |
||
33 | 3 | '0+(\\\\d\{20\})([$pathSeparator]|$)', |
|
34 | '\\\\1\\\\2' |
||
39 |