| Conditions | 10 |
| Paths | 108 |
| Total Lines | 66 |
| Code Lines | 46 |
| 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 |
||
| 104 | public function testTargetElementsCollection(): void |
||
| 105 | { |
||
| 106 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 107 | $flightPartners = [$this->birdo, $this->daffy, $this->daisy, $this->plucky]; |
||
| 108 | |||
| 109 | $this->assertCount(1, $referenceTargetElements); |
||
| 110 | $exists = false; |
||
| 111 | foreach ($referenceTargetElements as $ref) { |
||
| 112 | if ($ref->equals($this->daffy)) { |
||
| 113 | $exists = true; |
||
| 114 | break; |
||
| 115 | } |
||
| 116 | } |
||
| 117 | $this->assertTrue($exists); |
||
| 118 | |||
| 119 | $this->flightPartnerRefsColl->add($this->tweety, $this->daisy); |
||
| 120 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 121 | $this->assertCount(2, $referenceTargetElements); |
||
| 122 | |||
| 123 | $exists = false; |
||
| 124 | foreach ($referenceTargetElements as $ref) { |
||
| 125 | if ($ref->equals($this->daisy)) { |
||
| 126 | $exists = true; |
||
| 127 | break; |
||
| 128 | } |
||
| 129 | } |
||
| 130 | $this->assertTrue($exists); |
||
| 131 | |||
| 132 | $this->flightPartnerRefsColl->remove($this->tweety, $this->daisy); |
||
| 133 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 134 | $this->assertCount(1, $referenceTargetElements); |
||
| 135 | $exists = false; |
||
| 136 | foreach ($referenceTargetElements as $ref) { |
||
| 137 | if ($ref->equals($this->daffy)) { |
||
| 138 | $exists = true; |
||
| 139 | break; |
||
| 140 | } |
||
| 141 | } |
||
| 142 | $this->assertTrue($exists); |
||
| 143 | |||
| 144 | $this->flightPartnerRefsColl->addAll($this->tweety, $flightPartners); |
||
| 145 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 146 | $this->assertCount(4, $referenceTargetElements); |
||
| 147 | |||
| 148 | foreach ($flightPartners as $partner) { |
||
| 149 | $exists = false; |
||
| 150 | foreach ($referenceTargetElements as $ref) { |
||
| 151 | if ($ref->equals($partner)) { |
||
| 152 | $exists = true; |
||
| 153 | break; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | $this->assertTrue($exists); |
||
| 157 | } |
||
| 158 | |||
| 159 | $this->flightPartnerRefsColl->removeAll($this->tweety, $flightPartners); |
||
| 160 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 161 | $this->assertCount(0, $referenceTargetElements); |
||
| 162 | |||
| 163 | $this->flightPartnerRefsColl->addAll($this->tweety, $flightPartners); |
||
| 164 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 165 | $this->assertFalse(empty($referenceTargetElements)); |
||
| 166 | |||
| 167 | $this->flightPartnerRefsColl->clear($this->tweety); |
||
| 168 | $referenceTargetElements = $this->flightPartnerRefsColl->getReferenceTargetElements($this->tweety); |
||
| 169 | $this->assertTrue(empty($referenceTargetElements)); |
||
| 170 | } |
||
| 172 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.