| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 42 | public function createValidatorProvider(): array |
||
| 43 | { |
||
| 44 | return [ |
||
| 45 | 'empty-data' => [ |
||
| 46 | [], |
||
| 47 | false, |
||
| 48 | ], |
||
| 49 | 'valid-data' => [ |
||
| 50 | [ |
||
| 51 | 'identifier' => 'foo', |
||
| 52 | 'title' => 'Foo', |
||
| 53 | 'lede' => 'bar', |
||
| 54 | 'body' => 'baz', |
||
| 55 | 'is_draft' => '1', |
||
| 56 | 'category_id' => '5c032f90-bf10-4a77-81aa-b0b1254a8f66', |
||
| 57 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd40', |
||
| 58 | 'layout' => '', |
||
| 59 | 'header' => 'thud', |
||
| 60 | 'footer' => 'grunt', |
||
| 61 | 'css_files' => 'bletch', |
||
| 62 | 'js_files' => 'fum', |
||
| 63 | ], |
||
| 64 | true, |
||
| 65 | ], |
||
| 66 | 'valid-data-missing-all-not-required' => [ |
||
| 67 | [ |
||
| 68 | 'title' => 'Foo', |
||
| 69 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd40', |
||
| 70 | ], |
||
| 71 | true, |
||
| 72 | ], |
||
| 73 | 'valid-data-missing-all-not-required-with-layout' => [ |
||
| 74 | [ |
||
| 75 | 'title' => 'Foo', |
||
| 76 | 'layout' => 'qux', |
||
| 77 | ], |
||
| 78 | true, |
||
| 79 | ], |
||
| 80 | 'invalid-id-present' => [ |
||
| 81 | [ |
||
| 82 | 'id' => 'baf16ace-8fae-48a8-bbad-a610d7960e31', |
||
| 83 | 'title' => 'Foo', |
||
| 84 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd40', |
||
| 85 | ], |
||
| 86 | false, |
||
| 87 | ], |
||
| 88 | 'invalid-category-id-not-uuid' => [ |
||
| 89 | [ |
||
| 90 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd4', |
||
| 91 | ], |
||
| 92 | false, |
||
| 93 | ], |
||
| 94 | 'invalid-is-draft-is-not-numeric' => [ |
||
| 95 | [ |
||
| 96 | 'is_draft' => 'foo', |
||
| 97 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd40', |
||
| 98 | ], |
||
| 99 | false, |
||
| 100 | ], |
||
| 101 | 'invalid-layout-id-not-uuid' => [ |
||
| 102 | [ |
||
| 103 | 'category_id' => '5c032f90-bf10-4a77-81aa-b0b1254a8f6', |
||
| 104 | 'layout_id' => 'ebc97435-7280-4a67-855c-5d1ef0a2fd40', |
||
| 105 | ], |
||
| 106 | false, |
||
| 107 | ], |
||
| 126 |