| Conditions | 14 | 
| Paths | 60 | 
| Total Lines | 30 | 
| Code Lines | 16 | 
| 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  | 
            ||
| 34 | public static function compareVersions($stable, $latest, $required = null)  | 
            ||
| 35 |     { | 
            ||
| 36 | $state = self::STATE_UP_TO_DATE;  | 
            ||
| 37 | |||
| 38 | // prepare stable  | 
            ||
| 39 |         $stableArray = explode('.', $stable); | 
            ||
| 40 | $stableArray[0] = $stableArray[0][0] == 'v' ? substr($stableArray[0], 1) : $stableArray[0];  | 
            ||
| 41 | // prepare latest  | 
            ||
| 42 |         $latestArray = explode('.', $latest); | 
            ||
| 43 | $latestArray[0] = $latestArray[0][0] == 'v' ? substr($latestArray[0], 1) : $latestArray[0];  | 
            ||
| 44 | |||
| 45 |         if ($stableArray[0] != $latestArray[0] || (isset($stableArray[1]) && isset($latestArray[1]) && $stableArray[1] != $latestArray[1])) { | 
            ||
| 46 | $state = self::STATE_OUT_OF_DATE;  | 
            ||
| 47 |         } else if (isset($stableArray[2]) && isset($latestArray[2]) && $stableArray[2] != $latestArray[2]) { | 
            ||
| 48 | $state = self::STATE_PINNED_OUT_OF_DATE;  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 | // ToDo: The satisfies function didn't worked as expected. For example the constraint ~4.1 is not satisfying the version 4.9.5.  | 
            ||
| 52 |         if ($state != self::STATE_UP_TO_DATE && $required != null) { | 
            ||
| 53 |             try { | 
            ||
| 54 | $latestVersion = new version($latest);  | 
            ||
| 55 |                 if (!$latestVersion->satisfies(new expression($required))) { | 
            ||
| 56 | $state = self::STATE_UP_TO_DATE;  | 
            ||
| 57 | }  | 
            ||
| 58 |             } catch (SemVerException $e) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 59 | |||
| 60 | }  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 | return $state;  | 
            ||
| 64 | }  | 
            ||
| 65 | }  |