Conditions | 1 |
Paths | 1 |
Total Lines | 112 |
Code Lines | 76 |
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 |
||
43 | public function createValidatorProvider(): array |
||
44 | { |
||
45 | return [ |
||
46 | 'empty-data' => [ |
||
47 | [], |
||
48 | false, |
||
49 | ], |
||
50 | 'valid-data' => [ |
||
51 | [ |
||
52 | 'description' => 'foo', |
||
53 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
54 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
55 | 'name' => 'bar', |
||
56 | 'mime' => 'text/plain', |
||
57 | ], |
||
58 | true, |
||
59 | ], |
||
60 | 'valid-data-missing-all-not-required' => [ |
||
61 | [ |
||
62 | 'description' => 'foo', |
||
63 | 'name' => 'bar', |
||
64 | 'mime' => 'text/plain', |
||
65 | ], |
||
66 | true, |
||
67 | ], |
||
68 | 'invalid-id-present' => [ |
||
69 | [ |
||
70 | 'id' => '465c91df-9cc7-47e2-a2ef-8fe645753148', |
||
71 | 'description' => 'foo', |
||
72 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
73 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
74 | 'name' => 'bar', |
||
75 | 'mime' => 'text/plain', |
||
76 | ], |
||
77 | false, |
||
78 | ], |
||
79 | 'invalid-description-missing' => [ |
||
80 | [ |
||
81 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
82 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
83 | 'name' => 'bar', |
||
84 | 'mime' => 'text/plain', |
||
85 | ], |
||
86 | false, |
||
87 | ], |
||
88 | 'invalid-description-empty' => [ |
||
89 | [ |
||
90 | 'description' => '', |
||
91 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
92 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
93 | 'name' => 'bar', |
||
94 | 'mime' => 'text/plain', |
||
95 | ], |
||
96 | false, |
||
97 | ], |
||
98 | 'invalid-category-not-uuid' => [ |
||
99 | [ |
||
100 | 'description' => 'foo', |
||
101 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b05', |
||
102 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
103 | 'name' => 'bar', |
||
104 | 'mime' => 'text/plain', |
||
105 | ], |
||
106 | false, |
||
107 | ], |
||
108 | 'invalid-data' => [ |
||
109 | [ |
||
110 | 'description' => 'foo', |
||
111 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
112 | 'data' => '()*!@#$%)', |
||
113 | 'name' => 'bar', |
||
114 | 'mime' => 'text/plain', |
||
115 | ], |
||
116 | false, |
||
117 | ], |
||
118 | 'invalid-name-missing' => [ |
||
119 | [ |
||
120 | 'description' => 'foo', |
||
121 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
122 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
123 | 'mime' => 'text/plain', |
||
124 | ], |
||
125 | false, |
||
126 | ], |
||
127 | 'invalid-name-empty' => [ |
||
128 | [ |
||
129 | 'description' => 'foo', |
||
130 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
131 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
132 | 'name' => '', |
||
133 | 'mime' => 'text/plain', |
||
134 | ], |
||
135 | false, |
||
136 | ], |
||
137 | 'invalid-mime-missing' => [ |
||
138 | [ |
||
139 | 'description' => 'foo', |
||
140 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
141 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
142 | 'name' => 'bar', |
||
143 | ], |
||
144 | false, |
||
145 | ], |
||
146 | 'invalid-mime-empty' => [ |
||
147 | [ |
||
148 | 'description' => 'foo', |
||
149 | 'category_id' => '69da7b0b-8315-43c9-8f5d-a6a5ea09b051', |
||
150 | 'data' => 'aGVsbG8sIHdvcmxkIQ==', |
||
151 | 'name' => 'bar', |
||
152 | 'mime' => '', |
||
153 | ], |
||
154 | false, |
||
155 | ], |
||
176 |