Complex classes like CKEditorRenderer 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 CKEditorRenderer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 25 | class CKEditorRenderer implements CKEditorRendererInterface |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * @var JsonBuilder |
||
| 29 | */ |
||
| 30 | private $jsonBuilder; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var ContainerInterface |
||
| 34 | 1392 | */ |
|
| 35 | private $container; |
||
| 36 | 1392 | ||
| 37 | 1392 | /** |
|
| 38 | 1392 | * @param ContainerInterface $container |
|
| 39 | */ |
||
| 40 | public function __construct(ContainerInterface $container) |
||
| 45 | 170 | ||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | public function renderBasePath($basePath) |
||
| 53 | 153 | ||
| 54 | /** |
||
| 55 | * {@inheritdoc} |
||
| 56 | */ |
||
| 57 | public function renderJsPath($jsPath) |
||
| 61 | 1069 | ||
| 62 | 1069 | /** |
|
| 63 | 1069 | * {@inheritdoc} |
|
| 64 | 1006 | */ |
|
| 65 | 1069 | public function renderWidget($id, array $config, array $options = []) |
|
| 100 | 187 | ||
| 101 | /** |
||
| 102 | * {@inheritdoc} |
||
| 103 | */ |
||
| 104 | public function renderDestroy($id) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * {@inheritdoc} |
||
| 117 | */ |
||
| 118 | public function renderPlugin($name, array $plugin) |
||
| 127 | 48 | ||
| 128 | 48 | /** |
|
| 129 | 51 | * {@inheritdoc} |
|
| 130 | 48 | */ |
|
| 131 | public function renderStylesSet($name, array $stylesSet) |
||
| 145 | 68 | ||
| 146 | 68 | /** |
|
| 147 | 68 | * {@inheritdoc} |
|
| 148 | 64 | */ |
|
| 149 | 64 | public function renderTemplate($name, array $template) |
|
| 175 | |||
| 176 | 1069 | /** |
|
| 177 | 134 | * @param array $config |
|
| 178 | 126 | * |
|
| 179 | * @return array |
||
| 180 | 1069 | */ |
|
| 181 | private function fixConfigLanguage(array $config) |
||
| 193 | 136 | ||
| 194 | /** |
||
| 195 | 136 | * @param array $config |
|
| 196 | 136 | * |
|
| 197 | 136 | * @return array |
|
| 198 | 128 | */ |
|
| 199 | 128 | private function fixConfigContentsCss(array $config) |
|
| 212 | 1069 | ||
| 213 | /** |
||
| 214 | 1069 | * @param array $config |
|
| 215 | 1069 | * @param array $filebrowsers |
|
| 216 | 1006 | * |
|
| 217 | 1006 | * @return array |
|
| 218 | 1006 | */ |
|
| 219 | 1006 | private function fixConfigFilebrowsers(array $config, array $filebrowsers) |
|
| 257 | |||
| 258 | 1069 | /** |
|
| 259 | 17 | * @param array $config |
|
| 260 | 17 | */ |
|
| 261 | 16 | private function fixConfigEscapedValues(array $config) |
|
| 280 | |||
| 281 | /** |
||
| 282 | * @param string $json |
||
| 283 | 1069 | * |
|
| 284 | * @return string |
||
| 285 | 1069 | */ |
|
| 286 | private function fixConfigConstants($json) |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @param string $path |
||
| 293 | * |
||
| 294 | * @return string |
||
| 295 | 442 | */ |
|
| 296 | private function fixPath($path) |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @param string $url |
||
| 307 | * |
||
| 308 | * @return string |
||
| 309 | */ |
||
| 310 | private function fixUrl($url) |
||
| 316 | |||
| 317 | /** |
||
| 318 | * @return string|null |
||
| 319 | */ |
||
| 320 | private function getLanguage() |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return Request|null |
||
| 333 | */ |
||
| 334 | private function getRequest() |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return \Twig_Environment|EngineInterface |
||
| 341 | 1035 | */ |
|
| 342 | private function getTemplating() |
||
| 348 | 34 | ||
| 349 | /** |
||
| 350 | 935 | * @return Packages|null |
|
| 351 | */ |
||
| 352 | private function getAssets() |
||
| 356 | |||
| 357 | 1035 | /** |
|
| 358 | * @return RouterInterface |
||
| 359 | 1035 | */ |
|
| 360 | 32 | private function getRouter() |
|
| 364 | } |
||
| 365 |