Conditions | 1 |
Paths | 1 |
Total Lines | 197 |
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 |
||
38 | private function getGenresJson(): string |
||
39 | { |
||
40 | return <<<JSON |
||
41 | [ |
||
42 | { |
||
43 | "id": 28, |
||
44 | "name": "Action", |
||
45 | "translations": { |
||
46 | "en": "Action", |
||
47 | "ru": "Экшн", |
||
48 | "uk": "Екшн", |
||
49 | "pl": "Action" |
||
50 | } |
||
51 | }, |
||
52 | { |
||
53 | "id": 12, |
||
54 | "name": "Adventure", |
||
55 | "translations": { |
||
56 | "en": "Adventure", |
||
57 | "ru": "Приключения", |
||
58 | "uk": "Пригоди", |
||
59 | "pl": "Adventure" |
||
60 | } |
||
61 | }, |
||
62 | { |
||
63 | "id": 16, |
||
64 | "name": "Animation", |
||
65 | "translations": { |
||
66 | "en": "Animation", |
||
67 | "ru": "Анимация", |
||
68 | "uk": "Анімація", |
||
69 | "pl": "Animation" |
||
70 | } |
||
71 | }, |
||
72 | { |
||
73 | "id": 35, |
||
74 | "name": "Comedy", |
||
75 | "translations": { |
||
76 | "en": "Comedy", |
||
77 | "ru": "Комедия", |
||
78 | "uk": "Комедія", |
||
79 | "pl": "Comedy" |
||
80 | } |
||
81 | }, |
||
82 | { |
||
83 | "id": 80, |
||
84 | "name": "Crime", |
||
85 | "translations": { |
||
86 | "en": "Crime", |
||
87 | "ru": "Криминальный", |
||
88 | "uk": "Кримінальний", |
||
89 | "pl": "Crime" |
||
90 | } |
||
91 | }, |
||
92 | { |
||
93 | "id": 99, |
||
94 | "name": "Documentary", |
||
95 | "translations": { |
||
96 | "en": "Documentary", |
||
97 | "ru": "Документальный", |
||
98 | "uk": "Документальний", |
||
99 | "pl": "Documentary" |
||
100 | } |
||
101 | }, |
||
102 | { |
||
103 | "id": 18, |
||
104 | "name": "Drama", |
||
105 | "translations": { |
||
106 | "en": "Drama", |
||
107 | "ru": "Драма", |
||
108 | "uk": "Драма", |
||
109 | "pl": "Drama" |
||
110 | } |
||
111 | }, |
||
112 | { |
||
113 | "id": 10751, |
||
114 | "name": "Family", |
||
115 | "translations": { |
||
116 | "en": "Family", |
||
117 | "ru": "Семейный", |
||
118 | "uk": "Сімейний", |
||
119 | "pl": "Family" |
||
120 | } |
||
121 | }, |
||
122 | { |
||
123 | "id": 14, |
||
124 | "name": "Fantasy", |
||
125 | "translations": { |
||
126 | "en": "Fantasy", |
||
127 | "ru": "Фэнтези", |
||
128 | "uk": "Фентезі", |
||
129 | "pl": "Fantasy" |
||
130 | } |
||
131 | }, |
||
132 | { |
||
133 | "id": 36, |
||
134 | "name": "History", |
||
135 | "translations": { |
||
136 | "en": "History", |
||
137 | "ru": "Исторический", |
||
138 | "uk": "Історичний", |
||
139 | "pl": "History" |
||
140 | } |
||
141 | }, |
||
142 | { |
||
143 | "id": 27, |
||
144 | "name": "Horror", |
||
145 | "translations": { |
||
146 | "en": "Horror", |
||
147 | "ru": "Ужасы", |
||
148 | "uk": "Жахи", |
||
149 | "pl": "Horror" |
||
150 | } |
||
151 | }, |
||
152 | { |
||
153 | "id": 10402, |
||
154 | "name": "Music", |
||
155 | "translations": { |
||
156 | "en": "Music", |
||
157 | "ru": "Мюзикл", |
||
158 | "uk": "Мюзікл", |
||
159 | "pl": "Music" |
||
160 | } |
||
161 | }, |
||
162 | { |
||
163 | "id": 9648, |
||
164 | "name": "Mystery", |
||
165 | "translations": { |
||
166 | "en": "Mystery", |
||
167 | "ru": "Мистика", |
||
168 | "uk": "Містика", |
||
169 | "pl": "Mystery" |
||
170 | } |
||
171 | }, |
||
172 | { |
||
173 | "id": 10749, |
||
174 | "name": "Romance", |
||
175 | "translations": { |
||
176 | "en": "Romance", |
||
177 | "ru": "Роман", |
||
178 | "uk": "Роман", |
||
179 | "pl": "Romance" |
||
180 | } |
||
181 | }, |
||
182 | { |
||
183 | "id": 878, |
||
184 | "name": "Science Fiction", |
||
185 | "translations": { |
||
186 | "en": "Science Fiction", |
||
187 | "ru": "Научно-популярный", |
||
188 | "uk": "Науково-популярний", |
||
189 | "pl": "Science Fiction" |
||
190 | } |
||
191 | }, |
||
192 | { |
||
193 | "id": 10770, |
||
194 | "name": "TV Movie", |
||
195 | "translations": { |
||
196 | "en": "TV Movie", |
||
197 | "ru": "Телесериал", |
||
198 | "uk": "Телесеріал", |
||
199 | "pl": "TV Movie" |
||
200 | } |
||
201 | }, |
||
202 | { |
||
203 | "id": 53, |
||
204 | "name": "Thriller", |
||
205 | "translations": { |
||
206 | "en": "Thriller", |
||
207 | "ru": "Триллер", |
||
208 | "uk": "Триллер", |
||
209 | "pl": "Thriller" |
||
210 | } |
||
211 | }, |
||
212 | { |
||
213 | "id": 10752, |
||
214 | "name": "War", |
||
215 | "translations": { |
||
216 | "en": "War", |
||
217 | "ru": "Военный", |
||
218 | "uk": "Військовий", |
||
219 | "pl": "War" |
||
220 | } |
||
221 | }, |
||
222 | { |
||
223 | "id": 37, |
||
224 | "name": "Western", |
||
225 | "translations": { |
||
226 | "en": "Western", |
||
227 | "ru": "Вестерн", |
||
228 | "uk": "Вестерн", |
||
229 | "pl": "Western" |
||
230 | } |
||
231 | } |
||
232 | ] |
||
233 | JSON; |
||
234 | } |
||
235 | } |
||
236 |