| Conditions | 1 |
| Paths | 1 |
| Total Lines | 122 |
| Code Lines | 78 |
| 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 |
||
| 42 | public function provideCompareVersions() : array |
||
| 43 | { |
||
| 44 | return [ |
||
| 45 | // major |
||
| 46 | [ |
||
| 47 | Version::fromString('1.0.0'), |
||
| 48 | Version::fromString('2.0.0'), |
||
| 49 | -1, |
||
| 50 | '::compare() versions must be ordered by major version (current lower than other)', |
||
| 51 | ], |
||
| 52 | [ |
||
| 53 | Version::fromString('2.0.0'), |
||
| 54 | Version::fromString('1.0.0'), |
||
| 55 | 1, |
||
| 56 | '::compare() versions must be ordered by major version (current greater than other)', |
||
| 57 | ], |
||
| 58 | [ |
||
| 59 | Version::fromString('2.0.0'), |
||
| 60 | Version::fromString('10.0.0'), |
||
| 61 | -1, |
||
| 62 | '::compare() versions must be ordered by major version numerically', |
||
| 63 | ], |
||
| 64 | // minor |
||
| 65 | [ |
||
| 66 | Version::fromString('2.10.0'), |
||
| 67 | Version::fromString('2.0.0'), |
||
| 68 | 1, |
||
| 69 | '::compare() if major versions are equals, then it must be ordered by minor version (current lower than other)', |
||
| 70 | ], |
||
| 71 | [ |
||
| 72 | Version::fromString('2.0.0'), |
||
| 73 | Version::fromString('2.10.0'), |
||
| 74 | -1, |
||
| 75 | '::compare() if major versions are equals, then it must be ordered by minor version (current greater than other)', |
||
| 76 | ], |
||
| 77 | [ |
||
| 78 | Version::fromString('2.10.0'), |
||
| 79 | Version::fromString('2.2.0'), |
||
| 80 | 1, |
||
| 81 | '::compare() if major versions are equals, then it must be ordered by minor version numerically', |
||
| 82 | ], |
||
| 83 | // patch |
||
| 84 | [ |
||
| 85 | Version::fromString('2.0.10'), |
||
| 86 | Version::fromString('2.0.0'), |
||
| 87 | 1, |
||
| 88 | '::compare() if major and minor versions are equals, then it must be ordered by patch version numerically (current lower than other)', |
||
| 89 | ], |
||
| 90 | [ |
||
| 91 | Version::fromString('2.0.0'), |
||
| 92 | Version::fromString('2.0.10'), |
||
| 93 | -1, |
||
| 94 | '::compare() if major and minor versions are equals, then it must be ordered by patch version numerically (current greater than other)', |
||
| 95 | ], |
||
| 96 | [ |
||
| 97 | Version::fromString('2.0.10'), |
||
| 98 | Version::fromString('2.0.2'), |
||
| 99 | 1, |
||
| 100 | '::compare() if major and minor versions are equals, then it must be ordered by patch version numerically', |
||
| 101 | ], |
||
| 102 | [ |
||
| 103 | Version::fromString('2.0.0'), |
||
| 104 | Version::fromString('2.0.0+build'), |
||
| 105 | 0, |
||
| 106 | '::compare() if major, minor and patch versions are equals and both versions do not have pre-release, then they are equals', |
||
| 107 | ], |
||
| 108 | [ |
||
| 109 | Version::fromString('2.0.0'), |
||
| 110 | Version::fromString('2.0.0-alpha'), |
||
| 111 | 1, |
||
| 112 | '::compare() When major, minor, and patch are equal, a pre-release version has lower precedence than a normal version. (current without pre-release)', |
||
| 113 | ], |
||
| 114 | [ |
||
| 115 | Version::fromString('2.0.0-alpha'), |
||
| 116 | Version::fromString('2.0.0'), |
||
| 117 | -1, |
||
| 118 | '::compare() A larger set of pre-release fields has a higher precedence than a smaller set', |
||
| 119 | ], |
||
| 120 | [ |
||
| 121 | Version::fromString('2.0.0-alpha.1'), |
||
| 122 | Version::fromString('2.0.0-alpha'), |
||
| 123 | 1, |
||
| 124 | '::compare() A larger set of pre-release fields has a higher precedence than a smaller set (multiple level)', |
||
| 125 | ], |
||
| 126 | [ |
||
| 127 | Version::fromString('2.0.0-alpha'), |
||
| 128 | Version::fromString('2.0.0-alpha.1'), |
||
| 129 | -1, |
||
| 130 | '::compare() A larger set of pre-release fields has a higher precedence than a smaller set (multiple level)', |
||
| 131 | ], |
||
| 132 | [ |
||
| 133 | Version::fromString('2.0.0-1'), |
||
| 134 | Version::fromString('2.0.0-beta'), |
||
| 135 | -1, |
||
| 136 | '::compare() Precedence for two pre-release versions with the same major, minor, and patch version. Numeric identifiers always have lower precedence than non-numeric identifiers', |
||
| 137 | ], |
||
| 138 | [ |
||
| 139 | Version::fromString('2.0.0-beta'), |
||
| 140 | Version::fromString('2.0.0-1'), |
||
| 141 | 1, |
||
| 142 | '::compare() Precedence for two pre-release versions with the same major, minor, and patch version. Numeric identifiers always have lower precedence than non-numeric identifiers', |
||
| 143 | ], |
||
| 144 | [ |
||
| 145 | Version::fromString('2.0.0-alpha.1'), |
||
| 146 | Version::fromString('2.0.0-alpha.beta'), |
||
| 147 | -1, |
||
| 148 | '::compare() Precedence for two pre-release versions with the same major, minor, and patch version. Numeric identifiers always have lower precedence than non-numeric identifiers. Test with multiple identifiers level.', |
||
| 149 | ], |
||
| 150 | [ |
||
| 151 | Version::fromString('2.0.0-alpha.10'), |
||
| 152 | Version::fromString('2.0.0-alpha.2'), |
||
| 153 | 1, |
||
| 154 | '::compare() numeric pre-release, minor, and patch version. Numeric identifiers always have lower precedence than non-numeric identifiers. Test with multiple identifiers level.', |
||
| 155 | ], |
||
| 156 | [ |
||
| 157 | Version::fromString('2.0.0-alpha+build127'), |
||
| 158 | Version::fromString('2.0.0-alpha+build128'), |
||
| 159 | 0, |
||
| 160 | '::compare() numeric pre-release, minor, and patch version. Numeric identifiers always have lower precedence than non-numeric identifiers. Test with multiple identifiers level.', |
||
| 161 | ], |
||
| 162 | ]; |
||
| 163 | } |
||
| 164 | } |
||
| 165 |