| Conditions | 12 | 
| Paths | 16 | 
| Total Lines | 33 | 
| Code Lines | 21 | 
| 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  | 
            ||
| 20 | public static function isSerialized($data)  | 
            ||
| 21 |     { | 
            ||
| 22 |         if (!is_string($data)) { | 
            ||
| 23 | return false;  | 
            ||
| 24 | }  | 
            ||
| 25 | |||
| 26 | $data = trim($data);  | 
            ||
| 27 |         if ('N;' === $data) { | 
            ||
| 28 | return true;  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 |         if (!preg_match('/^([adObis]):/', $data, $badions)) { | 
            ||
| 32 | return false;  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 |         switch ($badions[1]) { | 
            ||
| 36 | case 'a':  | 
            ||
| 37 | case 'O':  | 
            ||
| 38 | case 's':  | 
            ||
| 39 |                 if (preg_match("/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data)) { | 
            ||
| 40 | return true;  | 
            ||
| 41 | }  | 
            ||
| 42 | break;  | 
            ||
| 43 | case 'b':  | 
            ||
| 44 | case 'i':  | 
            ||
| 45 | case 'd':  | 
            ||
| 46 |                 if (preg_match("/^{$badions[1]}:[0-9.E-]+;\$/", $data)) { | 
            ||
| 47 | return true;  | 
            ||
| 48 | }  | 
            ||
| 49 | break;  | 
            ||
| 50 | }  | 
            ||
| 51 | |||
| 52 | return false;  | 
            ||
| 53 | }  | 
            ||
| 54 | }  |