Complex classes like OC_Defaults 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 OC_Defaults, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 36 | class OC_Defaults { |
||
| 37 | private $theme; |
||
| 38 | private $l; |
||
| 39 | |||
| 40 | private $defaultEntity; |
||
| 41 | private $defaultName; |
||
| 42 | private $defaultTitle; |
||
| 43 | private $defaultBaseUrl; |
||
| 44 | private $defaultSyncClientUrl; |
||
| 45 | private $defaultiOSClientUrl; |
||
| 46 | private $defaultiTunesAppId; |
||
| 47 | private $defaultAndroidClientUrl; |
||
| 48 | private $defaultDocBaseUrl; |
||
| 49 | private $defaultDocVersion; |
||
| 50 | private $defaultSlogan; |
||
| 51 | private $defaultLogoClaim; |
||
| 52 | private $defaultMailHeaderColor; |
||
| 53 | /** |
||
| 54 | * @var IConfig |
||
| 55 | */ |
||
| 56 | private $config; |
||
| 57 | |||
| 58 | public function __construct() { |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param string $method |
||
| 93 | */ |
||
| 94 | private function themeExist($method) { |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Returns the base URL |
||
| 103 | * @return string URL |
||
| 104 | */ |
||
| 105 | public function getBaseUrl() { |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Returns the URL where the sync clients are listed |
||
| 115 | * @return string URL |
||
| 116 | */ |
||
| 117 | public function getSyncClientUrl() { |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Returns the URL to the App Store for the iOS Client |
||
| 127 | * @return string URL |
||
| 128 | */ |
||
| 129 | public function getiOSClientUrl() { |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Returns the AppId for the App Store for the iOS Client |
||
| 139 | * @return string AppId |
||
| 140 | */ |
||
| 141 | public function getiTunesAppId() { |
||
| 148 | |||
| 149 | /** |
||
| 150 | * Returns the URL to Google Play for the Android Client |
||
| 151 | * @return string URL |
||
| 152 | */ |
||
| 153 | public function getAndroidClientUrl() { |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Returns the documentation URL |
||
| 163 | * @return string URL |
||
| 164 | */ |
||
| 165 | public function getDocBaseUrl() { |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Returns the title |
||
| 175 | * @return string title |
||
| 176 | */ |
||
| 177 | public function getTitle() { |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Returns the short name of the software |
||
| 187 | * @return string title |
||
| 188 | */ |
||
| 189 | public function getName() { |
||
| 196 | |||
| 197 | /** |
||
| 198 | * Returns the short name of the software containing HTML strings |
||
| 199 | * @return string title |
||
| 200 | */ |
||
| 201 | public function getHTMLName() { |
||
| 208 | |||
| 209 | /** |
||
| 210 | * Returns entity (e.g. company name) - used for footer, copyright |
||
| 211 | * @return string entity name |
||
| 212 | */ |
||
| 213 | public function getEntity() { |
||
| 220 | |||
| 221 | /** |
||
| 222 | * Returns slogan |
||
| 223 | * @return string slogan |
||
| 224 | */ |
||
| 225 | public function getSlogan() { |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Returns logo claim |
||
| 235 | * @return string logo claim |
||
| 236 | */ |
||
| 237 | public function getLogoClaim() { |
||
| 244 | |||
| 245 | /** |
||
| 246 | * Returns short version of the footer |
||
| 247 | * @return string short footer |
||
| 248 | */ |
||
| 249 | public function getShortFooter() { |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Returns long version of the footer |
||
| 270 | * @return string long footer |
||
| 271 | */ |
||
| 272 | public function getLongFooter() { |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @param string $key |
||
| 284 | */ |
||
| 285 | public function buildDocLinkToKey($key) { |
||
| 291 | |||
| 292 | /** |
||
| 293 | * Returns mail header color |
||
| 294 | * @return string |
||
| 295 | */ |
||
| 296 | public function getMailHeaderColor() { |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Returns URL to imprint |
||
| 306 | * @return string |
||
| 307 | */ |
||
| 308 | public function getImprintUrl() { |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Returns URL to Privacy Policy |
||
| 318 | * @return string |
||
| 319 | */ |
||
| 320 | public function getPrivacyPolicyUrl() { |
||
| 327 | |||
| 328 | /** |
||
| 329 | * @internal Used for unit tests |
||
| 330 | * |
||
| 331 | * @param IConfig $config |
||
| 332 | */ |
||
| 333 | public function setConfig(IConfig $config) { |
||
| 336 | } |
||
| 337 |