| Conditions | 11 |
| Paths | 9 |
| Total Lines | 18 |
| Code Lines | 9 |
| 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 |
||
| 32 | public static function compareVersions($stable, $latest, $required = null) |
||
| 33 | { |
||
| 34 | $state = self::STATE_UP_TO_DATE; |
||
| 35 | |||
| 36 | if (explode('.', $stable)[0] != explode('.', $latest)[0] || (isset(explode('.', $stable)[1]) && isset(explode('.', $latest)[1]) && explode('.', $stable)[1] != explode('.', $latest)[1])) { |
||
| 37 | $state = self::STATE_OUT_OF_DATE; |
||
| 38 | } else if (isset(explode('.', $stable)[2]) && isset(explode('.', $latest)[2]) && explode('.', $stable)[2] != explode('.', $latest)[2]) { |
||
| 39 | $state = self::STATE_PINNED_OUT_OF_DATE; |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($state != self::STATE_UP_TO_DATE && $required != null) { |
||
| 43 | |||
| 44 | if (Semver::satisfies($stable,$required)) { |
||
| 45 | $state = self::STATE_UP_TO_DATE; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | return $state; |
||
| 50 | } |
||
| 51 | } |