| Conditions | 11 |
| Paths | 9 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 12 |
| Ratio | 42.86 % |
| 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 |
||
| 25 | private function s3ParamCheck() |
||
|
|
|||
| 26 | { |
||
| 27 | // S3に必要な設定がそろっているかチェックする |
||
| 28 | $s3Setting = Configure::read('ContentsFile.Setting.S3'); |
||
| 29 | View Code Duplication | if ( |
|
| 30 | !is_array($s3Setting) || |
||
| 31 | !array_key_exists('key', $s3Setting) || |
||
| 32 | !array_key_exists('secret', $s3Setting) || |
||
| 33 | !array_key_exists('bucket', $s3Setting) || |
||
| 34 | !array_key_exists('tmpDir', $s3Setting) || |
||
| 35 | !array_key_exists('fileDir', $s3Setting) || |
||
| 36 | !array_key_exists('workingDir', $s3Setting) |
||
| 37 | |||
| 38 | ) { |
||
| 39 | throw new InternalErrorException('contentsFileS3Config paramater shortage'); |
||
| 40 | } |
||
| 41 | |||
| 42 | // /が最後についていない場合はつける |
||
| 43 | if (!preg_match('#/$#', $s3Setting['tmpDir'])) { |
||
| 44 | Configure::write('ContentsFile.Setting.S3.tmpDir', $s3Setting['tmpDir'] . '/'); |
||
| 45 | } |
||
| 46 | if (!preg_match('#/$#', $s3Setting['fileDir'])) { |
||
| 47 | Configure::write('ContentsFile.Setting.S3.fileDir', $s3Setting['fileDir'] . '/'); |
||
| 48 | } |
||
| 49 | if (!preg_match('#/$#', $s3Setting['workingDir'])) { |
||
| 50 | Configure::write('ContentsFile.Setting.S3.workingDir', $s3Setting['workingDir'] . '/'); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 153 |