| Conditions | 10 |
| Paths | 4 |
| Total Lines | 26 |
| 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 |
||
| 53 | public function explodeParams($field , $paramsValue){ |
||
| 54 | $params = explode('|', $paramsValue); |
||
| 55 | $required = false; |
||
| 56 | $description = []; |
||
| 57 | $type = ''; |
||
| 58 | foreach($params as $param){ |
||
| 59 | if($param === 'required'){ |
||
| 60 | $required = true; |
||
| 61 | } |
||
| 62 | elseif($param === 'string' || $param === 'integer' ||$param === 'array' ||$param === 'boolean' ||$param === 'float' ||$param === 'number'|| $param === 'object'){ |
||
| 63 | $type = $param; |
||
| 64 | } |
||
| 65 | else{ |
||
| 66 | $description [] = $param; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | return [ |
||
| 71 | $field=> [ |
||
| 72 | 'type'=> $type, |
||
| 73 | 'description'=> implode(" ",$description), |
||
| 74 | 'required'=>$required, |
||
| 75 | 'value'=>$this->generateDummyValue($type) |
||
| 76 | ] |
||
| 77 | ]; |
||
| 78 | } |
||
| 79 | |||
| 81 | } |