| Conditions | 1 | 
| Total Lines | 147 | 
| 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 | ||
| 37 | public function dataProvider(): array | ||
| 38 |     { | ||
| 39 | return [ | ||
| 40 | [ | ||
| 41 |                 new class () { | ||
| 42 | }, | ||
| 43 | [], | ||
| 44 | ], | ||
| 45 | [ | ||
| 46 |                 new class () { | ||
| 47 | private $property1; | ||
| 48 | }, | ||
| 49 | [], | ||
| 50 | ], | ||
| 51 | [ | ||
| 52 |                 new class () { | ||
| 53 | #[NotRuleAttribute] | ||
| 54 | private $property1; | ||
| 55 | }, | ||
| 56 | [], | ||
| 57 | ], | ||
| 58 | [ | ||
| 59 |                 new class () { | ||
| 60 | #[Required()] | ||
| 61 | private $property1; | ||
| 62 | }, | ||
| 63 | [ | ||
| 64 | 'property1' => [ | ||
| 65 | new Required(), | ||
| 66 | ], | ||
| 67 | ], | ||
| 68 | ], | ||
| 69 | [ | ||
| 70 |                 new class () { | ||
| 71 | use TitleTrait; | ||
| 72 | }, | ||
| 73 | [ | ||
| 74 | 'title' => [ | ||
| 75 | new HasLength(max: 255), | ||
| 76 | ], | ||
| 77 | ], | ||
| 78 | ], | ||
| 79 | [ | ||
| 80 |                 new class () { | ||
| 81 | #[Required()] | ||
| 82 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 83 | private $property1; | ||
| 84 | #[Required()] | ||
| 85 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 86 | private $property2; | ||
| 87 | }, | ||
| 88 | [ | ||
| 89 | 'property1' => [ | ||
| 90 | new Required(), | ||
| 91 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 92 | ], | ||
| 93 | 'property2' => [ | ||
| 94 | new Required(), | ||
| 95 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 96 | ], | ||
| 97 | ], | ||
| 98 | ], | ||
| 99 | [ | ||
| 100 |                 new class () { | ||
| 101 | #[Each([ | ||
| 102 | new Required(), | ||
| 103 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 104 | ])] | ||
| 105 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 106 | private $property1; | ||
| 107 | }, | ||
| 108 | [ | ||
| 109 | 'property1' => [ | ||
| 110 | new Each([ | ||
| 111 | new Required(), | ||
| 112 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 113 | ]), | ||
| 114 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 115 | ], | ||
| 116 | ], | ||
| 117 | ], | ||
| 118 | [ | ||
| 119 |                 new class () { | ||
| 120 | #[Nested([ | ||
| 121 | new Required(), | ||
| 122 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 123 | ])] | ||
| 124 | #[Each([ | ||
| 125 | new Required(), | ||
| 126 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 127 | ])] | ||
| 128 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 129 | private $property1; | ||
| 130 | }, | ||
| 131 | [ | ||
| 132 | 'property1' => [ | ||
| 133 | new Nested([ | ||
| 134 | new Required(), | ||
| 135 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 136 | ]), | ||
| 137 | new Each([ | ||
| 138 | new Required(), | ||
| 139 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 140 | ]), | ||
| 141 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 142 | ], | ||
| 143 | ], | ||
| 144 | ], | ||
| 145 | [ | ||
| 146 |                 new class () { | ||
| 147 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 148 | #[HasLength(max: 255, skipOnEmpty: false)] | ||
| 149 | private $property1; | ||
| 150 | }, | ||
| 151 | [ | ||
| 152 | 'property1' => [ | ||
| 153 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 154 | new HasLength(max: 255, skipOnEmpty: false), | ||
| 155 | ], | ||
| 156 | ], | ||
| 157 | ], | ||
| 158 | [ | ||
| 159 |                 new class () { | ||
| 160 | #[Nested([ | ||
| 161 | new Required(), | ||
| 162 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 163 | ])] | ||
| 164 | #[Nested([ | ||
| 165 | new Required(), | ||
| 166 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 167 | ])] | ||
| 168 | #[HasLength(max: 255, skipOnEmpty: true)] | ||
| 169 | #[HasLength(max: 255, skipOnEmpty: false)] | ||
| 170 | private $property1; | ||
| 171 | }, | ||
| 172 | [ | ||
| 173 | 'property1' => [ | ||
| 174 | new Nested([ | ||
| 175 | new Required(), | ||
| 176 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 177 | ]), | ||
| 178 | new Nested([ | ||
| 179 | new Required(), | ||
| 180 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 181 | ]), | ||
| 182 | new HasLength(max: 255, skipOnEmpty: true), | ||
| 183 | new HasLength(max: 255, skipOnEmpty: false), | ||
| 184 | ], | ||
| 258 |