| 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 |
||
| 63 | public function testRowWithDateMultipleAndLogic(): void |
||
| 64 | { |
||
| 65 | $yesterday = new \DateTime('-1 days'); |
||
| 66 | $tomorrow = new \DateTime('+1 days'); |
||
| 67 | $this->insertDocumentWithDate(1, $yesterday); |
||
| 68 | $this->insertDocumentWithDate(2, $tomorrow); |
||
| 69 | |||
| 70 | /** @var ResponseInterface $res */ |
||
| 71 | $row = $this->r()->row('date')->eq($yesterday->format(\DateTime::ATOM))->and( |
||
| 72 | $this->r()->row('date')->ne($tomorrow->format(\DateTime::ATOM))->and( |
||
| 73 | $this->r()->row('id')->gt(0)->and( |
||
| 74 | $this->r()->row('id')->lt(3) |
||
| 75 | ) |
||
| 76 | ) |
||
| 77 | ); |
||
| 78 | |||
| 79 | $this->assertInstanceOf(RowInterface::class, $row); |
||
| 80 | $this->assertArraySubset( |
||
| 81 | [ |
||
| 82 | TermType::FUNC, |
||
| 83 | [ |
||
| 84 | [TermType::MAKE_ARRAY, [TermType::DATUM]], |
||
| 85 | [ |
||
| 86 | TermType::AND, |
||
| 87 | [ |
||
| 88 | [ |
||
| 89 | TermType::EQ, |
||
| 90 | [ |
||
| 91 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'date']], |
||
| 92 | $yesterday->format(\DateTime::ATOM), |
||
| 93 | ], |
||
| 94 | ], |
||
| 95 | [ |
||
| 96 | TermType::AND, |
||
| 97 | [ |
||
| 98 | [ |
||
| 99 | TermType::NE, |
||
| 100 | [ |
||
| 101 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'date']], |
||
| 102 | $tomorrow->format(\DateTime::ATOM), |
||
| 103 | ], |
||
| 104 | ], |
||
| 105 | [ |
||
| 106 | TermType::AND, |
||
| 107 | [ |
||
| 108 | [ |
||
| 109 | TermType::GT, |
||
| 110 | [ |
||
| 111 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'id']], |
||
| 112 | 0, |
||
| 113 | ], |
||
| 114 | ], |
||
| 115 | [ |
||
| 116 | TermType::LT, |
||
| 117 | [ |
||
| 118 | [TermType::GET_FIELD, [[TermType::IMPLICIT_VAR, []], 'id']], |
||
| 119 | 3, |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | ], |
||
| 123 | ], |
||
| 124 | ], |
||
| 125 | ], |
||
| 126 | ], |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | $row->toArray() |
||
| 131 | ); |
||
| 244 |