Conditions | 3 |
Paths | 4 |
Total Lines | 77 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
106 | public function getSyntax( $replacement = self::REPLACEMENT_NONE ) |
||
107 | { |
||
108 | |||
109 | if ( $this->queryStructure->getElement( QueryStructure::COUNT ) ) { |
||
110 | $this->queryStructure->replaceElement( QueryStructure::FIELDS, 'COUNT(*)' ); |
||
111 | $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
||
112 | $this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //??? |
||
113 | } |
||
114 | |||
115 | if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) |
||
116 | $this->queryStructure->setElement( QueryStructure::LIMIT, 1 ); |
||
117 | |||
118 | $syntax = array(); |
||
119 | |||
120 | /** |
||
121 | * Explain |
||
122 | */ |
||
123 | $syntax[] = $this->getExplainSyntax(); |
||
124 | |||
125 | /** |
||
126 | * SELECT statement |
||
127 | */ |
||
128 | $syntax[] = $this->statement; |
||
129 | |||
130 | /** |
||
131 | * PRIORITY |
||
132 | */ |
||
133 | $syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY ); |
||
134 | |||
135 | /** |
||
136 | * DISTINCT clause |
||
137 | */ |
||
138 | $syntax[] = $this->getDistinctSyntax(); |
||
139 | |||
140 | /** |
||
141 | * FIELDS |
||
142 | */ |
||
143 | $syntax[] = $this->getSelectFieldsSyntax(); |
||
144 | |||
145 | /** |
||
146 | * FROM table or queryStructure |
||
147 | */ |
||
148 | $syntax[] = 'FROM ' . $this->queryStructure->getElement( QueryStructure::TABLE ); |
||
149 | |||
150 | /** |
||
151 | * JOIN CLAUSES |
||
152 | */ |
||
153 | $syntax[] = $this->getJoinSyntax(); |
||
154 | |||
155 | /** |
||
156 | * WHERE clause |
||
157 | */ |
||
158 | $syntax[] = $this->getWhereSyntax(); |
||
159 | |||
160 | /** |
||
161 | * GROUP BY clause |
||
162 | */ |
||
163 | $syntax[] = $this->getGroupBySyntax(); |
||
164 | |||
165 | /** |
||
166 | * HAVING clause |
||
167 | */ |
||
168 | $syntax[] = $this->getHavingSyntax(); |
||
169 | |||
170 | /** |
||
171 | * ORDER BY clause |
||
172 | */ |
||
173 | $syntax[] = $this->getOrderBySyntax(); |
||
174 | |||
175 | /** |
||
176 | * LIMIT clause |
||
177 | */ |
||
178 | $syntax[] = $this->getLimitSyntax(); |
||
179 | |||
180 | $syntax = implode( ' ', $syntax ); |
||
181 | |||
182 | return $this->getSyntaxReplace( $syntax, $replacement ); |
||
183 | |||
207 | } |