| Conditions | 2 |
| Paths | 2 |
| Total Lines | 54 |
| Lines | 9 |
| Ratio | 16.67 % |
| 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 |
||
| 59 | $request = new Request(); |
||
| 60 | $request->attributes->set('siteaccess', $siteAccess); |
||
| 61 | $request->attributes->set('semanticPathinfo', '/foo/bar'); |
||
| 62 | $request->attributes->set('viewParametersString', '/(foo)/bar'); |
||
| 63 | |||
| 64 | return $request; |
||
| 65 | } |
||
| 66 | |||
| 67 | public function getRenderer(): FragmentRendererInterface |
||
| 68 | { |
||
| 69 | return new InlineFragmentRenderer($this->innerRenderer); |
||
| 70 | } |
||
| 71 | |||
| 72 | public function setAdditionalAsserts(ControllerReference $reference): void |
||
| 73 | { |
||
| 74 | $this->assertTrue(isset($reference->attributes['semanticPathinfo'])); |
||
| 75 | $this->assertSame('/foo/bar', $reference->attributes['semanticPathinfo']); |
||
| 76 | $this->assertTrue(isset($reference->attributes['viewParametersString'])); |
||
| 77 | $this->assertSame('/(foo)/bar', $reference->attributes['viewParametersString']); |
||
| 78 | } |
||
| 79 | } |
||
| 80 |