Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
Code Lines | 26 |
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 |
||
137 | public function testRowWithDateMultipleOrLogic(): void |
||
138 | { |
||
139 | $yesterday = new \DateTime('-1 days'); |
||
140 | $tomorrow = new \DateTime('+1 days'); |
||
141 | $this->insertDocumentWithDate(1, $yesterday); |
||
142 | $this->insertDocumentWithDate(2, $tomorrow); |
||
143 | |||
144 | /** @var ResponseInterface $res */ |
||
145 | $row = $this->r()->row('date')->eq($yesterday->format(\DateTime::ATOM))->or( |
||
146 | $this->r()->row('date')->ne($tomorrow->format(\DateTime::ATOM))->or( |
||
147 | $this->r()->row('id')->lt(3)->or( |
||
148 | $this->r()->row('id')->gt(0) |
||
149 | ) |
||
150 | ) |
||
151 | ); |
||
152 | |||
153 | $this->assertInstanceOf(RowInterface::class, $row); |
||
154 | $this->assertArraySubset( |
||
155 | [ |
||
156 | TermType::FUNC, |
||
157 | [ |
||
158 | [TermType::MAKE_ARRAY, [TermType::DATUM]], |
||
159 | [ |
||
160 | TermType::OR, |
||
161 | [ |
||
162 | [ |
||
163 | TermType::EQ, |
||
164 | [ |
||
165 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'date']], |
||
166 | $yesterday->format(\DateTime::ATOM), |
||
167 | ], |
||
168 | ], |
||
169 | [ |
||
170 | TermType::OR, |
||
171 | [ |
||
172 | [ |
||
173 | TermType::NE, |
||
174 | [ |
||
175 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'date']], |
||
176 | $tomorrow->format(\DateTime::ATOM), |
||
177 | ], |
||
178 | ], |
||
179 | [ |
||
180 | TermType::OR, |
||
181 | [ |
||
182 | [ |
||
183 | TermType::LT, |
||
184 | [ |
||
185 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'id']], |
||
186 | 3, |
||
187 | ], |
||
188 | ], |
||
189 | [ |
||
190 | TermType::GT, |
||
191 | [ |
||
192 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'id']], |
||
193 | 0, |
||
194 | ], |
||
195 | ], |
||
196 | ], |
||
197 | ], |
||
198 | ], |
||
199 | ], |
||
200 | ], |
||
201 | ], |
||
202 | ], |
||
203 | ], |
||
204 | $row->toArray() |
||
205 | ); |
||
244 |