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