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