| Conditions | 10 |
| Paths | 10 |
| Total Lines | 31 |
| Code Lines | 20 |
| 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 |
||
| 49 | public static function fromValue($value) |
||
| 50 | { |
||
| 51 | switch (gettype($value)) { |
||
| 52 | case 'string': |
||
| 53 | return INativeType::TYPE_STRING; |
||
| 54 | |||
| 55 | case 'integer': |
||
| 56 | return INativeType::TYPE_INT; |
||
| 57 | |||
| 58 | case 'boolean': |
||
| 59 | return INativeType::TYPE_BOOL; |
||
| 60 | |||
| 61 | case 'double': |
||
| 62 | return INativeType::TYPE_DOUBLE; |
||
| 63 | |||
| 64 | case 'NULL': |
||
| 65 | return INativeType::TYPE_NULL; |
||
| 66 | |||
| 67 | case 'array': |
||
| 68 | return INativeType::TYPE_ARRAY; |
||
| 69 | |||
| 70 | case 'resource': |
||
| 71 | case 'unknown type': |
||
| 72 | return INativeType::TYPE_RESOURCE; |
||
| 73 | |||
| 74 | case 'object': |
||
| 75 | return self::getObject(get_class($value)); |
||
| 76 | } |
||
| 77 | |||
| 78 | throw new PinqException('Unknown variable type %s given', gettype($value)); |
||
| 79 | } |
||
| 80 | } |
||
| 81 |