| Conditions | 7 |
| Paths | 7 |
| Total Lines | 57 |
| Code Lines | 30 |
| 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 |
||
| 126 | private function imageResizeMake($image, $imagetype, $imagePath, $baseSize, $imageSizeInfo) |
||
| 127 | { |
||
| 128 | // サイズ変更後の画像データを生成 |
||
| 129 | $outImage = ImageCreateTrueColor($imageSizeInfo['reSizeX'], $imageSizeInfo['reSizeY']); |
||
| 130 | if (!$outImage) { |
||
| 131 | // リサイズ後の画像作成失敗 |
||
| 132 | return false; |
||
| 133 | } |
||
| 134 | |||
| 135 | //透過GIF.PNG対策 |
||
| 136 | $this->setTPinfo($image, $imageSizeInfo['sizeX'], $imageSizeInfo['sizeY']); |
||
| 137 | |||
| 138 | // 画像で使用する色を透過度を指定して作成 |
||
| 139 | $bgcolor = imagecolorallocatealpha($outImage, @$this->tp["red"], @$this->tp["green"], @$this->tp["blue"], @$this->tp["alpha"]); |
||
| 140 | |||
| 141 | // 塗り潰す |
||
| 142 | imagefill($outImage, 0, 0, $bgcolor); |
||
| 143 | // 透明色を定義 |
||
| 144 | imagecolortransparent($outImage, $bgcolor); |
||
| 145 | //!透過GIF.PNG対策 |
||
| 146 | // 画像リサイズ |
||
| 147 | $ret = imagecopyresampled($outImage, $image, 0, 0, 0, 0, $imageSizeInfo['reSizeX'], $imageSizeInfo['reSizeY'], $imageSizeInfo['sizeX'], $imageSizeInfo['sizeY']); |
||
| 148 | |||
| 149 | if ($ret === false) { |
||
| 150 | // リサイズ失敗 |
||
| 151 | return false; |
||
| 152 | } |
||
| 153 | |||
| 154 | ImageDestroy($image); |
||
| 155 | |||
| 156 | // 画像保存 |
||
| 157 | $imagepathinfo = $this->getPathInfo($imagePath, $baseSize); |
||
| 158 | //resizeファイルを格納するディレクトリを作成 |
||
| 159 | if ( |
||
| 160 | !$this->mkdir($imagepathinfo['resize_dir'], 0777, true) |
||
| 161 | ) { |
||
| 162 | return false; |
||
| 163 | } |
||
| 164 | |||
| 165 | switch ($imagetype) { |
||
| 166 | case IMAGETYPE_GIF: |
||
| 167 | ImageGIF($outImage, $imagepathinfo['resize_filepath']); |
||
| 168 | break; |
||
| 169 | case IMAGETYPE_JPEG: |
||
| 170 | ImageJPEG($outImage, $imagepathinfo['resize_filepath'], 100); |
||
| 171 | break; |
||
| 172 | case IMAGETYPE_PNG: |
||
| 173 | ImagePNG($outImage, $imagepathinfo['resize_filepath']); |
||
| 174 | break; |
||
| 175 | default: |
||
| 176 | return false; |
||
| 177 | } |
||
| 178 | |||
| 179 | ImageDestroy($outImage); |
||
| 180 | |||
| 181 | return true; |
||
| 182 | } |
||
| 183 | |||
| 226 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.