Complex classes like Editor often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Editor, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
19 | class Editor extends BackendController |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Editor model instance |
||
24 | * @var \gplcart\modules\editor\models\Editor $editor |
||
25 | */ |
||
26 | protected $editor; |
||
27 | |||
28 | /** |
||
29 | * Module model instance |
||
30 | * @var \gplcart\core\models\Module $module |
||
31 | */ |
||
32 | protected $module; |
||
33 | |||
34 | /** |
||
35 | * The current module |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $data_module = array(); |
||
39 | |||
40 | /** |
||
41 | * The current module file |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $data_file; |
||
45 | |||
46 | /** |
||
47 | * @param EditorModuleModel $editor |
||
48 | * @param ModuleModel $module |
||
49 | */ |
||
50 | public function __construct(EditorModuleModel $editor, ModuleModel $module) |
||
57 | |||
58 | /** |
||
59 | * Route callback to display the select theme page |
||
60 | */ |
||
61 | public function themeEditor() |
||
70 | |||
71 | /** |
||
72 | * Set title on the select theme page |
||
73 | */ |
||
74 | protected function setTitleThemeEditor() |
||
78 | |||
79 | /** |
||
80 | * Set breadcrumbs on the select theme page |
||
81 | */ |
||
82 | protected function setBreadcrumbThemeEditor() |
||
98 | |||
99 | /** |
||
100 | * Output rendered templates on the select theme page |
||
101 | */ |
||
102 | protected function outputThemeEditor() |
||
106 | |||
107 | /** |
||
108 | * Displays the module file overview page |
||
109 | * @param integer $module_id |
||
110 | */ |
||
111 | public function listEditor($module_id) |
||
123 | |||
124 | /** |
||
125 | * Returns an array of module data |
||
126 | * @param string $module_id |
||
127 | * @return array |
||
128 | */ |
||
129 | protected function setModuleEditor($module_id) |
||
143 | |||
144 | /** |
||
145 | * Returns an array of files to edit |
||
146 | * @return array |
||
147 | */ |
||
148 | protected function getFilesEditor() |
||
153 | |||
154 | /** |
||
155 | * Prepares an array of files to be edited |
||
156 | * @param array $data |
||
157 | * @return array |
||
158 | */ |
||
159 | protected function prepareFilesEditor(array $data) |
||
188 | |||
189 | /** |
||
190 | * Sets title on theme files overview page |
||
191 | */ |
||
192 | protected function setTitleListEditor() |
||
197 | |||
198 | /** |
||
199 | * Sets breadcrumbs on theme files overview page |
||
200 | */ |
||
201 | protected function setBreadcrumbListEditor() |
||
222 | |||
223 | /** |
||
224 | * Renders templates of theme files overview page |
||
225 | */ |
||
226 | protected function outputListEditor() |
||
230 | |||
231 | /** |
||
232 | * Displays the file edit page |
||
233 | * @param string $module_id |
||
234 | * @param string $file_id |
||
235 | */ |
||
236 | public function editEditor($module_id, $file_id) |
||
256 | |||
257 | /** |
||
258 | * Sets messages on the file edit page |
||
259 | */ |
||
260 | protected function setMessageEditEditor() |
||
272 | |||
273 | /** |
||
274 | * Sets JavaScript settings on the file edit page |
||
275 | */ |
||
276 | protected function setJsSettingsEditor() |
||
285 | |||
286 | /** |
||
287 | * Saves an array of submitted data |
||
288 | */ |
||
289 | protected function submitEditor() |
||
295 | |||
296 | /** |
||
297 | * Validates a submitted data when editing a theme file |
||
298 | * @return bool |
||
299 | */ |
||
300 | protected function validateEditor() |
||
315 | |||
316 | /** |
||
317 | * Validates TWIG code |
||
318 | * @param string $content |
||
319 | * @return boolean |
||
320 | */ |
||
321 | protected function validateTwigEditor($content) |
||
341 | |||
342 | /** |
||
343 | * Writes a submitted content to a theme file |
||
344 | */ |
||
345 | protected function saveEditor() |
||
360 | |||
361 | /** |
||
362 | * Whether the current user can save the file |
||
363 | */ |
||
364 | protected function canSaveEditor() |
||
369 | |||
370 | /** |
||
371 | * Controls permissions to save a theme file for the current user |
||
372 | */ |
||
373 | protected function controlAccessSaveEditor() |
||
379 | |||
380 | /** |
||
381 | * Sets titles on the file edit page |
||
382 | */ |
||
383 | protected function setTitleEditEditor() |
||
389 | |||
390 | /** |
||
391 | * Sets breadcrumbs on the file edit page |
||
392 | */ |
||
393 | protected function setBreadcrumbEditEditor() |
||
414 | |||
415 | /** |
||
416 | * Renders the file edit page |
||
417 | */ |
||
418 | protected function outputEditEditor() |
||
422 | |||
423 | /** |
||
424 | * Returns a path to the file to be edited |
||
425 | * @param string $encoded_filename URL encoded base64 hash |
||
426 | * @return string |
||
427 | */ |
||
428 | protected function setFilePathEditor($encoded_filename) |
||
439 | |||
440 | /** |
||
441 | * Returns a content of the file |
||
442 | * @return string |
||
443 | */ |
||
444 | protected function getFileContentEditor() |
||
448 | |||
449 | /** |
||
450 | * Returns the total number of lines in the file |
||
451 | * @return integer |
||
452 | */ |
||
453 | protected function getFileTotalLinesEditor() |
||
457 | |||
458 | } |
||
459 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.