| Conditions | 12 |
| Paths | 257 |
| Total Lines | 65 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 65 | public function cImage($file, $conf) |
||
| 66 | { |
||
| 67 | $tsfe = $this->getTypoScriptFrontendController(); |
||
| 68 | $this->setSkipRealUrlImageInGetImgResource(true); |
||
| 69 | $info = $this->getImgResource($file, $conf['file.']); |
||
| 70 | $tsfe->lastImageInfo = $info; |
||
| 71 | if (!is_array($info)) { |
||
| 72 | return ''; |
||
| 73 | } |
||
| 74 | if (is_file(PATH_site . $info['3'])) { |
||
| 75 | $source = $tsfe->absRefPrefix . str_replace('%2F', '/', rawurlencode($info['3'])); |
||
| 76 | } else { |
||
| 77 | $source = $info[3]; |
||
| 78 | } |
||
| 79 | |||
| 80 | $layoutKey = $this->stdWrap($conf['layoutKey'], $conf['layoutKey.']); |
||
| 81 | $imageTagTemplate = $this->getImageTagTemplate($layoutKey, $conf); |
||
| 82 | $sourceCollection = $this->getImageSourceCollection($layoutKey, $conf, $file); |
||
| 83 | |||
| 84 | // This array is used to collect the image-refs on the page... |
||
| 85 | $tsfe->imagesOnPage[] = $source; |
||
| 86 | $altParam = $this->getAltParam($conf); |
||
| 87 | $params = $this->stdWrapValue('params', $conf); |
||
| 88 | if ($params !== '' && $params[0] !== ' ') { |
||
| 89 | $params = ' ' . $params; |
||
| 90 | } |
||
| 91 | |||
| 92 | $imageTagValues = [ |
||
| 93 | 'width' => (int)$info[0], |
||
| 94 | 'height' => (int)$info[1], |
||
| 95 | 'src' => htmlspecialchars($source), |
||
| 96 | 'params' => $params, |
||
| 97 | 'altParams' => $altParam, |
||
| 98 | 'border' => $this->getBorderAttr(' border="' . (int)$conf['border'] . '"'), |
||
| 99 | 'sourceCollection' => $sourceCollection, |
||
| 100 | 'selfClosingTagSlash' => (!empty($tsfe->xhtmlDoctype) ? ' /' : ''), |
||
| 101 | ]; |
||
| 102 | |||
| 103 | // ################################### |
||
| 104 | // ## Here begins RealUrl_image ###### |
||
| 105 | // ################################### |
||
| 106 | $tx_flrealurlimage = GeneralUtility::makeInstance(RealUrlImage::class); |
||
| 107 | $tx_flrealurlimage->start($this->data, $this->table); |
||
| 108 | $new_fileName = $tx_flrealurlimage->main($conf, $info, $file, $this); |
||
| 109 | $imageTagValues['src'] = $tx_flrealurlimage->addAbsRefPrefix($new_fileName); |
||
| 110 | // ################################## |
||
| 111 | // ### Here ends RealURL_Image ###### |
||
| 112 | // ################################## |
||
| 113 | |||
| 114 | $theValue = $this->templateService->substituteMarkerArray($imageTagTemplate, $imageTagValues, '###|###', true, true); |
||
| 115 | |||
| 116 | |||
| 117 | $linkWrap = isset($conf['linkWrap.']) ? $this->stdWrap($conf['linkWrap'], $conf['linkWrap.']) : $conf['linkWrap']; |
||
| 118 | if ($linkWrap) { |
||
| 119 | $theValue = $this->linkWrap($theValue, $linkWrap); |
||
| 120 | } elseif ($conf['imageLinkWrap']) { |
||
| 121 | $originalFile = !empty($info['originalFile']) ? $info['originalFile'] : $info['origFile']; |
||
| 122 | $theValue = $this->imageLinkWrap($theValue, $originalFile, $conf['imageLinkWrap.']); |
||
| 123 | } |
||
| 124 | $wrap = isset($conf['wrap.']) ? $this->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap']; |
||
| 125 | if ((string)$wrap !== '') { |
||
| 126 | $theValue = $this->wrap($theValue, $conf['wrap']); |
||
| 127 | } |
||
| 128 | return $theValue; |
||
| 129 | } |
||
| 130 | |||
| 189 |