Complex classes like CheckSetupController 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 CheckSetupController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 47 | class CheckSetupController extends Controller { |
||
| 48 | /** @var IConfig */ |
||
| 49 | private $config; |
||
| 50 | /** @var IClientService */ |
||
| 51 | private $clientService; |
||
| 52 | /** @var \OC_Util */ |
||
| 53 | private $util; |
||
| 54 | /** @var IURLGenerator */ |
||
| 55 | private $urlGenerator; |
||
| 56 | /** @var IL10N */ |
||
| 57 | private $l10n; |
||
| 58 | /** @var Checker */ |
||
| 59 | private $checker; |
||
| 60 | /** @var ILogger */ |
||
| 61 | private $logger; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param string $AppName |
||
| 65 | * @param IRequest $request |
||
| 66 | * @param IConfig $config |
||
| 67 | * @param IClientService $clientService |
||
| 68 | * @param IURLGenerator $urlGenerator |
||
| 69 | * @param \OC_Util $util |
||
| 70 | * @param IL10N $l10n |
||
| 71 | * @param Checker $checker |
||
| 72 | * @param ILogger $logger |
||
| 73 | */ |
||
| 74 | public function __construct($AppName, |
||
| 75 | IRequest $request, |
||
| 76 | IConfig $config, |
||
| 77 | IClientService $clientService, |
||
| 78 | IURLGenerator $urlGenerator, |
||
| 79 | \OC_Util $util, |
||
| 80 | IL10N $l10n, |
||
| 81 | Checker $checker, |
||
| 82 | ILogger $logger) { |
||
| 83 | parent::__construct($AppName, $request); |
||
| 84 | $this->config = $config; |
||
| 85 | $this->clientService = $clientService; |
||
| 86 | $this->util = $util; |
||
| 87 | $this->urlGenerator = $urlGenerator; |
||
| 88 | $this->l10n = $l10n; |
||
| 89 | $this->checker = $checker; |
||
| 90 | $this->logger = $logger; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Checks if the ownCloud server can connect to the internet using HTTPS and HTTP |
||
| 95 | * @return bool |
||
| 96 | */ |
||
| 97 | private function isInternetConnectionWorking() { |
||
| 98 | if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
||
| 99 | return false; |
||
| 100 | } |
||
| 101 | |||
| 102 | $siteArray = ['www.nextcloud.com', |
||
| 103 | 'www.google.com', |
||
| 104 | 'www.github.com']; |
||
| 105 | |||
| 106 | foreach($siteArray as $site) { |
||
| 107 | if ($this->isSiteReachable($site)) { |
||
| 108 | return true; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | return false; |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Chceks if the ownCloud server can connect to a specific URL using both HTTPS and HTTP |
||
| 116 | * @return bool |
||
| 117 | */ |
||
| 118 | private function isSiteReachable($sitename) { |
||
| 119 | $httpSiteName = 'http://' . $sitename . '/'; |
||
| 120 | $httpsSiteName = 'https://' . $sitename . '/'; |
||
| 121 | |||
| 122 | try { |
||
| 123 | $client = $this->clientService->newClient(); |
||
| 124 | $client->get($httpSiteName); |
||
| 125 | $client->get($httpsSiteName); |
||
| 126 | } catch (\Exception $e) { |
||
| 127 | $this->logger->logException($e, ['app' => 'internet_connection_check']); |
||
| 128 | return false; |
||
| 129 | } |
||
| 130 | return true; |
||
| 131 | } |
||
| 132 | |||
| 133 | /** |
||
| 134 | * Checks whether a local memcache is installed or not |
||
| 135 | * @return bool |
||
| 136 | */ |
||
| 137 | private function isMemcacheConfigured() { |
||
| 140 | |||
| 141 | /** |
||
| 142 | * Whether /dev/urandom is available to the PHP controller |
||
| 143 | * |
||
| 144 | * @return bool |
||
| 145 | */ |
||
| 146 | private function isUrandomAvailable() { |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Public for the sake of unit-testing |
||
| 160 | * |
||
| 161 | * @return array |
||
| 162 | */ |
||
| 163 | protected function getCurlVersion() { |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
||
| 169 | * have multiple bugs which likely lead to problems in combination with |
||
| 170 | * functionality required by ownCloud such as SNI. |
||
| 171 | * |
||
| 172 | * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
||
| 173 | * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
||
| 174 | * @return string |
||
| 175 | */ |
||
| 176 | private function isUsedTlsLibOutdated() { |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Whether the version is outdated |
||
| 238 | * |
||
| 239 | * @return bool |
||
| 240 | */ |
||
| 241 | protected function isPhpOutdated() { |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Whether the php version is still supported (at time of release) |
||
| 251 | * according to: https://secure.php.net/supported-versions.php |
||
| 252 | * |
||
| 253 | * @return array |
||
| 254 | */ |
||
| 255 | private function isPhpSupported() { |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Check if the reverse proxy configuration is working as expected |
||
| 261 | * |
||
| 262 | * @return bool |
||
| 263 | */ |
||
| 264 | private function forwardedForHeadersWorking() { |
||
| 275 | |||
| 276 | /** |
||
| 277 | * Checks if the correct memcache module for PHP is installed. Only |
||
| 278 | * fails if memcached is configured and the working module is not installed. |
||
| 279 | * |
||
| 280 | * @return bool |
||
| 281 | */ |
||
| 282 | private function isCorrectMemcachedPHPModuleInstalled() { |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @return RedirectResponse |
||
| 295 | */ |
||
| 296 | public function rescanFailedIntegrityCheck() { |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @NoCSRFRequired |
||
| 305 | * @return DataResponse |
||
| 306 | */ |
||
| 307 | public function getFailedIntegrityCheckFiles() { |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @return DataResponse |
||
| 365 | */ |
||
| 366 | public function check() { |
||
| 384 | } |
||
| 385 |
Scrutinizer analyzes your
composer.json/composer.lockfile 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.