We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 13 |
| Paths | 20 |
| Total Lines | 46 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 158 | protected function loadDocument(array $requestData, int $pid): void |
||
| 159 | { |
||
| 160 | // Try to get document format from database |
||
| 161 | if (!empty($requestData['id'])) { |
||
| 162 | $this->initializeRepositories($pid); |
||
| 163 | $doc = null; |
||
| 164 | $this->document = null; |
||
| 165 | if (MathUtility::canBeInterpretedAsInteger($requestData['id'])) { |
||
| 166 | // find document from repository by uid |
||
| 167 | $this->document = $this->documentRepository->findOneByIdAndSettings((int) $requestData['id'], ['storagePid' => $pid]); |
||
| 168 | if ($this->document) { |
||
| 169 | $doc = AbstractDocument::getInstance($this->document->getLocation(), ['storagePid' => $pid], true); |
||
| 170 | } else { |
||
| 171 | $this->logger->error('Invalid UID "' . $requestData['id'] . '" or PID "' . $pid . '" for document loading'); |
||
| 172 | } |
||
| 173 | } elseif (GeneralUtility::isValidUrl($requestData['id'])) { |
||
| 174 | $doc = AbstractDocument::getInstance($requestData['id'], ['storagePid' => $pid], true); |
||
| 175 | |||
| 176 | if ($doc !== null) { |
||
| 177 | if ($doc->recordId) { |
||
| 178 | $this->document = $this->documentRepository->findOneByRecordId($doc->recordId); |
||
| 179 | } |
||
| 180 | if (!isset($this->document)) { |
||
| 181 | // create new dummy Document object |
||
| 182 | $this->document = GeneralUtility::makeInstance(Document::class); |
||
| 183 | } |
||
| 184 | $this->document->setLocation($requestData['id']); |
||
| 185 | } else { |
||
| 186 | $this->logger->error('Invalid location given "' . $requestData['id'] . '" for document loading'); |
||
| 187 | } |
||
| 188 | } |
||
| 189 | if ($this->document !== null && $doc !== null) { |
||
| 190 | $this->document->setCurrentDocument($doc); |
||
| 191 | } |
||
| 192 | } elseif (!empty($requestData['recordId'])) { |
||
| 193 | $this->document = $this->documentRepository->findOneByRecordId($requestData['recordId']); |
||
| 194 | if ($this->document !== null) { |
||
| 195 | $doc = AbstractDocument::getInstance($this->document->getLocation(), ['storagePid' => $pid], true); |
||
| 196 | if ($doc !== null) { |
||
| 197 | $this->document->setCurrentDocument($doc); |
||
| 198 | } else { |
||
| 199 | $this->logger->error('Failed to load document with record ID "' . $requestData['recordId'] . '"'); |
||
| 200 | } |
||
| 201 | } |
||
| 202 | } else { |
||
| 203 | $this->logger->error('Empty UID or invalid PID "' . $pid . '" for document loading'); |
||
| 204 | } |
||
| 223 |
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.