We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 14 |
Paths | 432 |
Total Lines | 93 |
Code Lines | 49 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
87 | protected function showCollectionList() |
||
88 | { |
||
89 | |||
90 | $result = $this->collectionRepository->getCollections($this->settings, $GLOBALS['TSFE']->fe_user->user['uid'], $GLOBALS['TSFE']->sys_language_uid); |
||
91 | $count = $result['count']; |
||
92 | $result = $result['result']; |
||
93 | |||
94 | if ($count == 1 && empty($this->settings['dont_show_single'])) { |
||
95 | $resArray = $result->fetch(); |
||
96 | $this->showSingleCollection(intval($resArray['uid'])); |
||
97 | } |
||
98 | $solr = Solr::getInstance($this->settings['solrcore']); |
||
99 | if (!$solr->ready) { |
||
100 | $this->logger->error('Apache Solr not available'); |
||
101 | //return $content; |
||
102 | } |
||
103 | // We only care about the UID and partOf in the results and want them sorted |
||
104 | $params['fields'] = 'uid,partof'; |
||
105 | $params['sort'] = ['uid' => 'asc']; |
||
106 | $collections = []; |
||
107 | |||
108 | // Get language overlay if on alterative website language. |
||
109 | $pageRepository = GeneralUtility::makeInstance(PageRepository::class); |
||
110 | while ($collectionData = $result->fetch()) { |
||
111 | if ($collectionData['sys_language_uid'] != $GLOBALS['TSFE']->sys_language_content) { |
||
112 | $collections[$collectionData['uid']] = $pageRepository->getRecordOverlay('tx_dlf_collections', $collectionData, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL); |
||
113 | // keep the index_name of the default language |
||
114 | $collections[$collectionData['uid']]['index_name'] = $collectionData['index_name']; |
||
115 | } else { |
||
116 | $collections[$collectionData['uid']] = $collectionData; |
||
117 | } |
||
118 | } |
||
119 | // Sort collections according to flexform configuration |
||
120 | if ($this->settings['collections']) { |
||
121 | $sortedCollections = []; |
||
122 | foreach (GeneralUtility::intExplode(',', $this->settings['collections']) as $uid) { |
||
123 | $sortedCollections[$uid] = $collections[$uid]; |
||
124 | } |
||
125 | $collections = $sortedCollections; |
||
126 | } |
||
127 | |||
128 | $processedCollections = []; |
||
129 | |||
130 | // Process results. |
||
131 | foreach ($collections as $collection) { |
||
132 | $solr_query = ''; |
||
133 | if ($collection['index_query'] != '') { |
||
134 | $solr_query .= '(' . $collection['index_query'] . ')'; |
||
135 | } else { |
||
136 | $solr_query .= 'collection:("' . $collection['index_name'] . '")'; |
||
137 | } |
||
138 | $partOfNothing = $solr->search_raw($solr_query . ' AND partof:0 AND toplevel:true', $params); |
||
139 | $partOfSomething = $solr->search_raw($solr_query . ' AND NOT partof:0 AND toplevel:true', $params); |
||
140 | // Titles are all documents that are "root" elements i.e. partof == 0 |
||
141 | $collection['titles'] = []; |
||
142 | foreach ($partOfNothing as $doc) { |
||
143 | $collection['titles'][$doc->uid] = $doc->uid; |
||
144 | } |
||
145 | // Volumes are documents that are both |
||
146 | // a) "leaf" elements i.e. partof != 0 |
||
147 | // b) "root" elements that are not referenced by other documents ("root" elements that have no descendants) |
||
148 | $collection['volumes'] = $collection['titles']; |
||
149 | foreach ($partOfSomething as $doc) { |
||
150 | $collection['volumes'][$doc->uid] = $doc->uid; |
||
151 | // If a document is referenced via partof, it’s not a volume anymore. |
||
152 | unset($collection['volumes'][$doc->partof]); |
||
153 | } |
||
154 | |||
155 | // Generate random but unique array key taking priority into account. |
||
156 | do { |
||
157 | $_key = ($collection['priority'] * 1000) + mt_rand(0, 1000); |
||
158 | } while (!empty($processedCollections[$_key])); |
||
159 | |||
160 | $collection['countTitles'] = count($collection['titles']); |
||
161 | $collection['countVolumes'] = count($collection['volumes']); |
||
162 | |||
163 | $processedCollections[$_key] = $collection; |
||
164 | } |
||
165 | |||
166 | // Randomize sorting? |
||
167 | if (!empty($this->settings['randomize'])) { |
||
168 | ksort($processedCollections, SORT_NUMERIC); |
||
169 | } |
||
170 | |||
171 | // TODO: Hook for getting custom collection hierarchies/subentries (requested by SBB). |
||
172 | /* foreach ($this->hookObjects as $hookObj) { |
||
173 | if (method_exists($hookObj, 'showCollectionList_getCustomCollectionList')) { |
||
174 | $hookObj->showCollectionList_getCustomCollectionList($this, $this->settings['templateFile'], $content, $markerArray); |
||
175 | } |
||
176 | } |
||
177 | */ |
||
178 | |||
179 | $this->view->assign('collections', $processedCollections); |
||
180 | } |
||
316 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.