We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 10 |
| Paths | 14 |
| Total Lines | 52 |
| Code Lines | 34 |
| 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 |
||
| 96 | protected function getRawTextFromXml($id) |
||
| 97 | { |
||
| 98 | $rawText = ''; |
||
| 99 | // Load available text formats, ... |
||
| 100 | $this->loadFormats(); |
||
| 101 | // ... physical structure ... |
||
| 102 | $this->_getPhysicalStructure(); |
||
| 103 | // ... and extension configuration. |
||
| 104 | $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey); |
||
| 105 | $fileGrpsFulltext = GeneralUtility::trimExplode(',', $extConf['fileGrpFulltext']); |
||
| 106 | if (!empty($this->physicalStructureInfo[$id])) { |
||
| 107 | while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) { |
||
| 108 | if (!empty($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])) { |
||
| 109 | // Get full text file. |
||
| 110 | $file = GeneralUtility::getUrl($this->getFileLocation($this->physicalStructureInfo[$id]['files'][$fileGrpFulltext])); |
||
| 111 | if ($file !== false) { |
||
| 112 | $rawTextXml = Helper::getXmlFileAsString($file); |
||
|
|
|||
| 113 | // Get the root element's name as text format. |
||
| 114 | $textFormat = strtoupper($rawTextXml->getName()); |
||
| 115 | } else { |
||
| 116 | $this->logger->warning('Couldn\'t load fulltext file for structure node @ID "' . $id . '"'); |
||
|
1 ignored issue
–
show
|
|||
| 117 | return $rawText; |
||
| 118 | } |
||
| 119 | break; |
||
| 120 | } |
||
| 121 | } |
||
| 122 | } else { |
||
| 123 | $this->logger->warning('Invalid structure node @ID "' . $id . '"'); |
||
| 124 | return $rawText; |
||
| 125 | } |
||
| 126 | // Is this text format supported? |
||
| 127 | if ( |
||
| 128 | !empty($rawTextXml) |
||
| 129 | && !empty($this->formats[$textFormat]) |
||
| 130 | ) { |
||
| 131 | if (!empty($this->formats[$textFormat]['class'])) { |
||
| 132 | $class = $this->formats[$textFormat]['class']; |
||
| 133 | // Get the raw text from class. |
||
| 134 | if ( |
||
| 135 | class_exists($class) |
||
| 136 | && ($obj = GeneralUtility::makeInstance($class)) instanceof FulltextInterface |
||
| 137 | ) { |
||
| 138 | $rawText = $obj->getRawText($rawTextXml); |
||
| 139 | $this->rawTextArray[$id] = $rawText; |
||
| 140 | } else { |
||
| 141 | $this->logger->warning('Invalid class/method "' . $class . '->getRawText()" for text format "' . $textFormat . '"'); |
||
| 142 | } |
||
| 143 | } |
||
| 144 | } else { |
||
| 145 | $this->logger->warning('Unsupported text format "' . $textFormat . '" in physical node with @ID "' . $id . '"'); |
||
| 146 | } |
||
| 147 | return $rawText; |
||
| 148 | } |
||
| 163 |
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.