1 | <?php |
||
11 | class OrderByAnalyzer |
||
12 | { |
||
13 | /** |
||
14 | * The content of the cache variable. |
||
15 | * |
||
16 | * @var Cache |
||
17 | */ |
||
18 | private $cache; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $cachePrefix; |
||
24 | |||
25 | /** |
||
26 | * OrderByAnalyzer constructor. |
||
27 | * @param Cache $cache |
||
28 | * @param string|null $cachePrefix |
||
29 | */ |
||
30 | public function __construct(Cache $cache, $cachePrefix = null) |
||
35 | |||
36 | /** |
||
37 | * Returns an array for each sorted "column" in the form: |
||
38 | * |
||
39 | * [ |
||
40 | * [ |
||
41 | * 'type' => 'colref', |
||
42 | * 'table' => null, |
||
43 | * 'column' => 'a', |
||
44 | * 'direction' => 'ASC' |
||
45 | * ], |
||
46 | * [ |
||
47 | * 'type' => 'expr', |
||
48 | * 'expr' => 'RAND()', |
||
49 | * 'direction' => 'DESC' |
||
50 | * ] |
||
51 | * ] |
||
52 | * |
||
53 | * @param string $orderBy |
||
54 | * @return array |
||
55 | */ |
||
56 | public function analyzeOrderBy(string $orderBy) : array |
||
67 | |||
68 | private function analyzeOrderByNoCache(string $orderBy) : array |
||
116 | |||
117 | /** |
||
118 | * Trims the ASC/DESC direction at the end of the string. |
||
119 | * |
||
120 | * @param string $sql |
||
121 | * @return string |
||
122 | */ |
||
123 | private function trimDirection(string $sql) : string |
||
129 | } |
||
130 |