Conditions | 1 |
Total Lines | 62 |
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 |
||
73 | public function dataPropertyVisibility(): array |
||
74 | { |
||
75 | return [ |
||
76 | 'class-name-and-private-protected-public' => [ |
||
77 | [ |
||
78 | 'name' => [Required::class], |
||
79 | 'age' => [Number::class], |
||
80 | 'number' => [Number::class], |
||
81 | ], |
||
82 | ObjectWithDifferentPropertyVisibility::class, |
||
83 | ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PUBLIC, |
||
84 | ], |
||
85 | 'class-name-and-private' => [ |
||
86 | [ |
||
87 | 'number' => [Number::class], |
||
88 | ], |
||
89 | ObjectWithDifferentPropertyVisibility::class, |
||
90 | ReflectionProperty::IS_PRIVATE, |
||
91 | ], |
||
92 | 'class-name-and-protected' => [ |
||
93 | [ |
||
94 | 'age' => [Number::class], |
||
95 | ], |
||
96 | ObjectWithDifferentPropertyVisibility::class, |
||
97 | ReflectionProperty::IS_PROTECTED, |
||
98 | ], |
||
99 | 'class-name-and-public' => [ |
||
100 | [ |
||
101 | 'name' => [Required::class], |
||
102 | ], |
||
103 | ObjectWithDifferentPropertyVisibility::class, |
||
104 | ReflectionProperty::IS_PUBLIC, |
||
105 | ], |
||
106 | 'object-and-private-protected-public' => [ |
||
107 | [ |
||
108 | 'name' => [Required::class], |
||
109 | 'age' => [Number::class], |
||
110 | 'number' => [Number::class], |
||
111 | ], |
||
112 | new ObjectWithDifferentPropertyVisibility(), |
||
113 | ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PUBLIC, |
||
114 | ], |
||
115 | 'object-and-private' => [ |
||
116 | [ |
||
117 | 'number' => [Number::class], |
||
118 | ], |
||
119 | new ObjectWithDifferentPropertyVisibility(), |
||
120 | ReflectionProperty::IS_PRIVATE, |
||
121 | ], |
||
122 | 'object-and-protected' => [ |
||
123 | [ |
||
124 | 'age' => [Number::class], |
||
125 | ], |
||
126 | new ObjectWithDifferentPropertyVisibility(), |
||
127 | ReflectionProperty::IS_PROTECTED, |
||
128 | ], |
||
129 | 'object-and-public' => [ |
||
130 | [ |
||
131 | 'name' => [Required::class], |
||
132 | ], |
||
133 | new ObjectWithDifferentPropertyVisibility(), |
||
134 | ReflectionProperty::IS_PUBLIC, |
||
135 | ], |
||
220 |