Conditions | 10 |
Paths | 7 |
Total Lines | 34 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Return the LIMIT clause ready for inserting into a query. |
||
68 | * |
||
69 | * @param SQLSelect $query The expression object to build from |
||
70 | * @param array $parameters Out parameter for the resulting query parameters |
||
71 | * @return string The finalised limit SQL fragment |
||
72 | */ |
||
73 | public function buildLimitFragment(SQLSelect $query, array &$parameters) |
||
74 | { |
||
75 | $nl = $this->getSeparator(); |
||
76 | |||
77 | // Ensure limit is given |
||
78 | $limit = $query->getLimit(); |
||
79 | if (empty($limit)) { |
||
80 | return ''; |
||
81 | } |
||
82 | |||
83 | // For literal values return this as the limit SQL |
||
84 | if (! is_array($limit)) { |
||
85 | return "{$nl}LIMIT $limit"; |
||
86 | } |
||
87 | |||
88 | // Assert that the array version provides the 'limit' key |
||
89 | if (! array_key_exists('limit', $limit) || ($limit['limit'] !== null && ! is_numeric($limit['limit']))) { |
||
90 | throw new InvalidArgumentException( |
||
91 | 'SQLite3QueryBuilder::buildLimitSQL(): Wrong format for $limit: '. var_export($limit, true) |
||
92 | ); |
||
93 | } |
||
94 | |||
95 | $clause = "{$nl}"; |
||
96 | if ($limit['limit'] !== null) { |
||
97 | $clause .= "LIMIT {$limit['limit']} "; |
||
98 | } else { |
||
108 |