Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
134 | public function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder |
||
135 | { |
||
136 | $query = $this->connection->createQueryBuilder(); |
||
137 | $expr = $query->expr(); |
||
138 | |||
139 | $query |
||
140 | ->select( |
||
141 | 'v.id AS ezcontentobject_version_id', |
||
142 | 'v.version AS ezcontentobject_version_version', |
||
143 | 'v.modified AS ezcontentobject_version_modified', |
||
144 | 'v.creator_id AS ezcontentobject_version_creator_id', |
||
145 | 'v.created AS ezcontentobject_version_created', |
||
146 | 'v.status AS ezcontentobject_version_status', |
||
147 | 'v.contentobject_id AS ezcontentobject_version_contentobject_id', |
||
148 | 'v.initial_language_id AS ezcontentobject_version_initial_language_id', |
||
149 | 'v.language_mask AS ezcontentobject_version_language_mask', |
||
150 | // Content main location |
||
151 | 't.main_node_id AS ezcontentobject_tree_main_node_id', |
||
152 | // Content object |
||
153 | 'c.id AS ezcontentobject_id', |
||
154 | 'c.contentclass_id AS ezcontentobject_contentclass_id', |
||
155 | 'c.section_id AS ezcontentobject_section_id', |
||
156 | 'c.owner_id AS ezcontentobject_owner_id', |
||
157 | 'c.remote_id AS ezcontentobject_remote_id', |
||
158 | 'c.current_version AS ezcontentobject_current_version', |
||
159 | 'c.initial_language_id AS ezcontentobject_initial_language_id', |
||
160 | 'c.modified AS ezcontentobject_modified', |
||
161 | 'c.published AS ezcontentobject_published', |
||
162 | 'c.status AS ezcontentobject_status', |
||
163 | 'c.name AS ezcontentobject_name', |
||
164 | 'c.language_mask AS ezcontentobject_language_mask', |
||
165 | 'c.is_hidden AS ezcontentobject_is_hidden' |
||
166 | ) |
||
167 | ->from(Gateway::CONTENT_VERSION_TABLE, 'v') |
||
168 | ->innerJoin( |
||
169 | 'v', |
||
170 | Gateway::CONTENT_ITEM_TABLE, |
||
171 | 'c', |
||
172 | $expr->eq('c.id', 'v.contentobject_id') |
||
173 | ) |
||
174 | ->leftJoin( |
||
175 | 'v', |
||
176 | 'ezcontentobject_tree', |
||
177 | 't', |
||
178 | $expr->andX( |
||
179 | $expr->eq('t.contentobject_id', 'v.contentobject_id'), |
||
180 | $expr->eq('t.main_node_id', 't.node_id') |
||
181 | ) |
||
182 | ); |
||
183 | |||
184 | return $query; |
||
185 | } |
||
186 | } |
||
187 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.