Conditions | 1 |
Paths | 1 |
Total Lines | 172 |
Code Lines | 132 |
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 declare(strict_types=1); |
||
24 | public function initializeMediaFixtures(): void |
||
25 | { |
||
26 | $thumbnailSize150Id = Uuid::randomHex(); |
||
27 | $thumbnailSize300Id = Uuid::randomHex(); |
||
28 | |||
29 | $this->mediaFixtures = [ |
||
30 | 'NamedEmpty' => [ |
||
31 | 'id' => Uuid::randomHex(), |
||
32 | ], |
||
33 | 'NamedMimePng' => [ |
||
34 | 'id' => Uuid::randomHex(), |
||
35 | 'mimeType' => 'image/png', |
||
36 | 'fileSize' => 1024, |
||
37 | 'mediaType' => new ImageType(), |
||
38 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
39 | ], |
||
40 | 'NamedMimePngEtxPng' => [ |
||
41 | 'id' => Uuid::randomHex(), |
||
42 | 'mimeType' => 'image/png', |
||
43 | 'fileExtension' => 'png', |
||
44 | 'fileName' => 'pngFileWithExtension', |
||
45 | 'fileSize' => 1024, |
||
46 | 'mediaType' => new ImageType(), |
||
47 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
48 | ], |
||
49 | 'NamedMimeTxtEtxTxt' => [ |
||
50 | 'id' => Uuid::randomHex(), |
||
51 | 'mimeType' => 'plain/txt', |
||
52 | 'fileExtension' => 'txt', |
||
53 | 'fileName' => 'textFileWithExtension', |
||
54 | 'fileSize' => 1024, |
||
55 | 'mediaType' => new BinaryType(), |
||
56 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
57 | ], |
||
58 | 'NamedMimeJpgEtxJpg' => [ |
||
59 | 'id' => Uuid::randomHex(), |
||
60 | 'mimeType' => 'image/jpg', |
||
61 | 'fileExtension' => 'jpg', |
||
62 | 'fileName' => 'jpgFileWithExtension', |
||
63 | 'fileSize' => 1024, |
||
64 | 'mediaType' => new ImageType(), |
||
65 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
66 | ], |
||
67 | 'NamedMimePdfEtxPdf' => [ |
||
68 | 'id' => Uuid::randomHex(), |
||
69 | 'mimeType' => 'application/pdf', |
||
70 | 'fileExtension' => 'pdf', |
||
71 | 'fileName' => 'pdfFileWithExtension', |
||
72 | 'fileSize' => 1024, |
||
73 | 'mediaType' => new DocumentType(), |
||
74 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
75 | ], |
||
76 | 'NamedWithThumbnail' => [ |
||
77 | 'id' => Uuid::randomHex(), |
||
78 | 'thumbnails' => [ |
||
79 | [ |
||
80 | 'width' => 200, |
||
81 | 'height' => 200, |
||
82 | 'highDpi' => false, |
||
83 | ], |
||
84 | ], |
||
85 | ], |
||
86 | 'MediaWithProduct' => [ |
||
87 | 'id' => Uuid::randomHex(), |
||
88 | 'mimeType' => 'image/png', |
||
89 | 'fileExtension' => 'png', |
||
90 | 'fileName' => 'pngFileWithProduct', |
||
91 | 'productMedia' => [ |
||
92 | [ |
||
93 | 'id' => Uuid::randomHex(), |
||
94 | 'product' => [ |
||
95 | 'id' => Uuid::randomHex(), |
||
96 | 'productNumber' => Uuid::randomHex(), |
||
97 | 'price' => ['gross' => 10, 'net' => 9, 'linked' => false], |
||
98 | 'stock' => 10, |
||
99 | 'manufacturer' => [ |
||
100 | 'name' => 'test', |
||
101 | ], |
||
102 | 'name' => 'product', |
||
103 | 'tax' => [ |
||
104 | 'taxRate' => 13, |
||
105 | 'name' => 'green', |
||
106 | ], |
||
107 | ], |
||
108 | ], |
||
109 | ], |
||
110 | ], |
||
111 | 'MediaWithManufacturer' => [ |
||
112 | 'id' => Uuid::randomHex(), |
||
113 | 'mimeType' => 'image/png', |
||
114 | 'fileExtension' => 'png', |
||
115 | 'fileName' => 'pngFileWithManufacturer', |
||
116 | 'productManufacturers' => [ |
||
117 | [ |
||
118 | 'id' => Uuid::randomHex(), |
||
119 | 'name' => 'manufacturer', |
||
120 | ], |
||
121 | ], |
||
122 | ], |
||
123 | 'NamedMimePngEtxPngWithFolder' => [ |
||
124 | 'id' => Uuid::randomHex(), |
||
125 | 'mimeType' => 'image/png', |
||
126 | 'fileExtension' => 'png', |
||
127 | 'fileName' => 'pngFileWithExtensionAndFolder', |
||
128 | 'fileSize' => 1024, |
||
129 | 'mediaType' => new ImageType(), |
||
130 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
131 | 'mediaFolder' => [ |
||
132 | 'name' => 'test folder', |
||
133 | 'useParentConfiguration' => false, |
||
134 | 'configuration' => [ |
||
135 | 'createThumbnails' => true, |
||
136 | 'keepAspectRatio' => true, |
||
137 | 'thumbnailQuality' => 80, |
||
138 | 'mediaThumbnailSizes' => [ |
||
139 | [ |
||
140 | 'id' => $thumbnailSize150Id, |
||
141 | 'width' => 150, |
||
142 | 'height' => 150, |
||
143 | ], |
||
144 | [ |
||
145 | 'id' => $thumbnailSize300Id, |
||
146 | 'width' => 300, |
||
147 | 'height' => 300, |
||
148 | ], |
||
149 | ], |
||
150 | ], |
||
151 | ], |
||
152 | ], |
||
153 | 'NamedMimeJpgEtxJpgWithFolder' => [ |
||
154 | 'id' => Uuid::randomHex(), |
||
155 | 'mimeType' => 'image/jpg', |
||
156 | 'fileExtension' => 'jpg', |
||
157 | 'fileName' => 'jpgFileWithExtensionAndFolder', |
||
158 | 'fileSize' => 1024, |
||
159 | 'mediaType' => new ImageType(), |
||
160 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
161 | 'mediaFolder' => [ |
||
162 | 'name' => 'test folder', |
||
163 | 'useParentConfiguration' => false, |
||
164 | 'configuration' => [ |
||
165 | 'createThumbnails' => true, |
||
166 | 'keepAspectRatio' => true, |
||
167 | 'thumbnailQuality' => 80, |
||
168 | 'mediaThumbnailSizes' => [ |
||
169 | [ |
||
170 | 'id' => $thumbnailSize150Id, |
||
171 | 'width' => 150, |
||
172 | 'height' => 150, |
||
173 | ], |
||
174 | [ |
||
175 | 'id' => $thumbnailSize300Id, |
||
176 | 'width' => 300, |
||
177 | 'height' => 300, |
||
178 | ], |
||
179 | ], |
||
180 | ], |
||
181 | ], |
||
182 | ], |
||
183 | 'NamedMimeJpgEtxJpgWithFolderWithoutThumbnails' => [ |
||
184 | 'id' => Uuid::randomHex(), |
||
185 | 'mimeType' => 'image/jpg', |
||
186 | 'fileExtension' => 'jpg', |
||
187 | 'fileName' => 'jpgFileWithExtensionAndCatalog', |
||
188 | 'fileSize' => 1024, |
||
189 | 'mediaType' => new ImageType(), |
||
190 | 'uploadedAt' => new \DateTime('2011-01-01T15:03:01.012345Z'), |
||
191 | 'mediaFolder' => [ |
||
192 | 'name' => 'test folder', |
||
193 | 'useParentConfiguration' => false, |
||
194 | 'configuration' => [ |
||
195 | 'createThumbnails' => false, |
||
196 | ], |
||
271 |