| Conditions | 17 |
| Paths | 40 |
| Total Lines | 67 |
| Code Lines | 39 |
| 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 |
||
| 60 | public function dumpAction(ServerRequestInterface $request): ResponseInterface |
||
| 61 | { |
||
| 62 | $parameters = $this->buildParametersFromRequest($request); |
||
| 63 | |||
| 64 | if (!$this->isTokenValid($parameters, $request)) { |
||
| 65 | return (new Response())->withStatus(403); |
||
| 66 | } |
||
| 67 | $file = $this->createFileObjectByParameters($parameters); |
||
| 68 | if ($file === null) { |
||
| 69 | return (new Response())->withStatus(404); |
||
| 70 | } |
||
| 71 | |||
| 72 | // Hook: allow some other process to do some security/access checks. Hook should return 403 response if access is rejected, void otherwise |
||
| 73 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['FileDumpEID.php']['checkFileAccess'] ?? [] as $className) { |
||
| 74 | $hookObject = GeneralUtility::makeInstance($className); |
||
| 75 | if (!$hookObject instanceof FileDumpEIDHookInterface) { |
||
| 76 | throw new \UnexpectedValueException($className . ' must implement interface ' . FileDumpEIDHookInterface::class, 1394442417); |
||
| 77 | } |
||
| 78 | $response = $hookObject->checkFileAccess($file); |
||
| 79 | if ($response instanceof ResponseInterface) { |
||
| 80 | return $response; |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | $processingInstructions = []; |
||
| 85 | |||
| 86 | // Apply cropping, if possible |
||
| 87 | if (!empty($parameters['cv'])) { |
||
| 88 | $cropVariant = $parameters['cv']; |
||
| 89 | $cropString = $file instanceof FileReference ? $file->getProperty('crop') : ''; |
||
| 90 | $cropArea = CropVariantCollection::create((string)$cropString)->getCropArea($cropVariant); |
||
| 91 | $processingInstructions = array_merge( |
||
| 92 | $processingInstructions, |
||
| 93 | [ |
||
| 94 | 'crop' => $cropArea->isEmpty() ? null : $cropArea->makeAbsoluteBasedOnFile($file), |
||
| 95 | ] |
||
| 96 | ); |
||
| 97 | } |
||
| 98 | |||
| 99 | // Apply width/height, if given |
||
| 100 | if (!empty($parameters['s'])) { |
||
| 101 | $size = GeneralUtility::trimExplode(':', $parameters['s']); |
||
| 102 | $processingInstructions = array_merge( |
||
| 103 | $processingInstructions, |
||
| 104 | [ |
||
| 105 | 'width' => $size[0] ?? null, |
||
| 106 | 'height' => $size[1] ?? null, |
||
| 107 | 'minWidth' => $size[2] ? (int)$size[2] : null, |
||
| 108 | 'minHeight' => $size[3] ? (int)$size[3] : null, |
||
| 109 | 'maxWidth' => $size[4] ? (int)$size[4] : null, |
||
| 110 | 'maxHeight' => $size[5] ? (int)$size[5] : null |
||
| 111 | ] |
||
| 112 | ); |
||
| 113 | } |
||
| 114 | |||
| 115 | if (!empty($processingInstructions) && !($file instanceof ProcessedFile)) { |
||
| 116 | if (is_callable([$file, 'getOriginalFile'])) { |
||
| 117 | // Get the original file from the file reference |
||
| 118 | $file = $file->getOriginalFile(); |
||
|
|
|||
| 119 | } |
||
| 120 | $file = $file->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $processingInstructions); |
||
| 121 | } |
||
| 122 | |||
| 123 | return $file->getStorage()->streamFile( |
||
| 124 | $file, |
||
| 125 | (bool)($parameters['dl'] ?? false), |
||
| 126 | $parameters['fn'] ?? null |
||
| 127 | ); |
||
| 234 |
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.