| Conditions | 4 |
| Paths | 4 |
| Total Lines | 52 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 52 | public function getStatus(): array |
||
| 53 | { |
||
| 54 | $reports = []; |
||
| 55 | $solrConnections = GeneralUtility::makeInstance(ConnectionManager::class)->getAllConnections(); |
||
| 56 | |||
| 57 | foreach ($solrConnections as $solrConnection) { |
||
| 58 | $coreAdmin = $solrConnection->getAdminService(); |
||
| 59 | /** @var $solrConnection SolrConnection */ |
||
| 60 | if (!$coreAdmin->ping()) { |
||
| 61 | $url = $coreAdmin->__toString(); |
||
| 62 | $pingFailedMsg = 'Could not ping solr server, can not check version ' . $url; |
||
| 63 | $status = GeneralUtility::makeInstance( |
||
| 64 | Status::class, |
||
| 65 | /** @scrutinizer ignore-type */ |
||
| 66 | 'Apache Solr Version', |
||
| 67 | /** @scrutinizer ignore-type */ |
||
| 68 | 'Not accessible', |
||
| 69 | /** @scrutinizer ignore-type */ |
||
| 70 | $pingFailedMsg, |
||
| 71 | /** @scrutinizer ignore-type */ |
||
| 72 | ContextualFeedbackSeverity::ERROR |
||
| 73 | ); |
||
| 74 | $reports[] = $status; |
||
| 75 | continue; |
||
| 76 | } |
||
| 77 | |||
| 78 | $solrVersion = $coreAdmin->getSolrServerVersion(); |
||
| 79 | $isOutdatedVersion = version_compare($this->getCleanSolrVersion($solrVersion), self::REQUIRED_SOLR_VERSION, '<'); |
||
| 80 | |||
| 81 | if (!$isOutdatedVersion) { |
||
| 82 | continue; |
||
| 83 | } |
||
| 84 | |||
| 85 | $formattedVersion = $this->formatSolrVersion($solrVersion); |
||
| 86 | $variables = ['requiredVersion' => self::REQUIRED_SOLR_VERSION, 'currentVersion' => $formattedVersion, 'solr' => $coreAdmin]; |
||
| 87 | $report = $this->getRenderedReport('SolrVersionStatus.html', $variables); |
||
| 88 | $status = GeneralUtility::makeInstance( |
||
| 89 | Status::class, |
||
| 90 | /** @scrutinizer ignore-type */ |
||
| 91 | 'Apache Solr Version', |
||
| 92 | /** @scrutinizer ignore-type */ |
||
| 93 | 'Outdated, Unsupported', |
||
| 94 | /** @scrutinizer ignore-type */ |
||
| 95 | $report, |
||
| 96 | /** @scrutinizer ignore-type */ |
||
| 97 | ContextualFeedbackSeverity::ERROR |
||
| 98 | ); |
||
| 99 | |||
| 100 | $reports[] = $status; |
||
| 101 | } |
||
| 102 | |||
| 103 | return $reports; |
||
| 104 | } |
||
| 151 |