| Conditions | 1 |
| Paths | 1 |
| Total Lines | 76 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 25 | public function parsingSuccessProvider(): array |
||
| 26 | { |
||
| 27 | $attributes = Attributes::fromArray(['f' => 'foo', 'b' => 'bar']); |
||
| 28 | |||
| 29 | return [ |
||
| 30 | 'empty' => ['', []], |
||
| 31 | 'fail' => ['', []], |
||
| 32 | 'templates-only-1' => [ |
||
| 33 | '{{block/content-one-1}}', |
||
| 34 | [ |
||
| 35 | 'block' => |
||
| 36 | [ |
||
| 37 | 'content-one-1' => [ |
||
| 38 | new ParsedTemplate('block', 'content-one-1', null, ['{{block/content-one-1}}']), |
||
| 39 | ], |
||
| 40 | ], |
||
| 41 | ], |
||
| 42 | ], |
||
| 43 | 'templates-only-2' => [ |
||
| 44 | '{{block/content-one-1}} {{ block/content-2-two }}', |
||
| 45 | [ |
||
| 46 | 'block' => [ |
||
| 47 | 'content-2-two' => [ |
||
| 48 | new ParsedTemplate('block', 'content-2-two', null, ['{{ block/content-2-two }}']), |
||
| 49 | ], |
||
| 50 | 'content-one-1' => [ |
||
| 51 | new ParsedTemplate('block', 'content-one-1', null, ['{{block/content-one-1}}']), |
||
| 52 | ], |
||
| 53 | ], |
||
| 54 | ], |
||
| 55 | ], |
||
| 56 | 'templates-only-3' => [ |
||
| 57 | '{{block/layout-one-1}} {{ block/layout-2-two }} {{block/layout-one-1 }}', |
||
| 58 | [ |
||
| 59 | 'block' => [ |
||
| 60 | 'layout-2-two' => [ |
||
| 61 | new ParsedTemplate('block', 'layout-2-two', null, ['{{ block/layout-2-two }}']), |
||
| 62 | ], |
||
| 63 | 'layout-one-1' => [ |
||
| 64 | new ParsedTemplate( |
||
| 65 | 'block', |
||
| 66 | 'layout-one-1', |
||
| 67 | null, |
||
| 68 | ['{{block/layout-one-1}}', '{{block/layout-one-1 }}'] |
||
| 69 | ), |
||
| 70 | ], |
||
| 71 | ], |
||
| 72 | ], |
||
| 73 | ], |
||
| 74 | 'template-with-attribute' => [ |
||
| 75 | '{{block/layout-one-1 f="foo" b="bar"}}', |
||
| 76 | [ |
||
| 77 | 'block' => [ |
||
| 78 | 'layout-one-1' => [ |
||
| 79 | new ParsedTemplate( |
||
| 80 | 'block', |
||
| 81 | 'layout-one-1', |
||
| 82 | $attributes, |
||
| 83 | ['{{block/layout-one-1 f="foo" b="bar"}}'] |
||
| 84 | ), |
||
| 85 | ], |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | ], |
||
| 89 | 'templates-with-attributes' => [ |
||
| 90 | '{{block/layout-one-1 f="foo" b="bar"}} {{block/layout-one-1 b="bar" f="foo"}}', // phpcs:ignore |
||
| 91 | [ |
||
| 92 | 'block' => [ |
||
| 93 | 'layout-one-1' => [ |
||
| 94 | new ParsedTemplate( |
||
| 95 | 'block', |
||
| 96 | 'layout-one-1', |
||
| 97 | $attributes, |
||
| 98 | [ |
||
| 99 | '{{block/layout-one-1 f="foo" b="bar"}}', |
||
| 100 | '{{block/layout-one-1 b="bar" f="foo"}}', |
||
| 101 | ] |
||
| 243 |