| Conditions | 7 |
| Paths | 9 |
| Total Lines | 52 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 |
||
| 130 | public function render() |
||
| 131 | { |
||
| 132 | $arguments = $this->arguments['arguments']; |
||
| 133 | $pageUid = $this->arguments['pageUid']; |
||
| 134 | $apiPid = $this->arguments['apiPid']; |
||
| 135 | $class = $this->arguments['class']; |
||
| 136 | |||
| 137 | if ($arguments['document']) { |
||
| 138 | |||
| 139 | // it's already a document object? |
||
| 140 | if ($arguments['document'] instanceof \EWW\Dpf\Domain\Model\Document) { |
||
| 141 | |||
| 142 | $document = $arguments['document']; |
||
| 143 | |||
| 144 | } else if (MathUtility::canBeInterpretedAsInteger($arguments['document'])) { |
||
| 145 | |||
| 146 | $document = $this->documentRepository->findByUid($arguments['document']); |
||
| 147 | |||
| 148 | } |
||
| 149 | |||
| 150 | // we found a valid document |
||
| 151 | if ($document) { |
||
|
|
|||
| 152 | |||
| 153 | $row['qid'] = $document->getUid(); |
||
| 154 | |||
| 155 | $row['action'] = 'preview'; |
||
| 156 | |||
| 157 | } else { |
||
| 158 | |||
| 159 | // ok, nothing to render. So return empty content. |
||
| 160 | return ''; |
||
| 161 | |||
| 162 | } |
||
| 163 | |||
| 164 | } else if ($arguments['documentObjectIdentifier']) { |
||
| 165 | |||
| 166 | $row['action'] = 'mets'; |
||
| 167 | |||
| 168 | $row['qid'] = $arguments['documentObjectIdentifier']; |
||
| 169 | |||
| 170 | // pass configured API secret key parameter to enable dissemination of inactive documents |
||
| 171 | if (isset($this->secretKey)) { |
||
| 172 | $row['deliverInactive'] = $this->secretKey; |
||
| 173 | } |
||
| 174 | |||
| 175 | } |
||
| 176 | |||
| 177 | $insideText = $this->renderChildren(); |
||
| 178 | |||
| 179 | $content = $this->getViewIcon($row, $pageUid, $apiPid, $insideText, $class); |
||
| 180 | |||
| 181 | return $content; |
||
| 182 | |||
| 185 |