| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @copyright   (c) 2014-2017 brian ridley | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author      brian ridley <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @license     http://opensource.org/licenses/MIT MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace ptlis\SemanticVersion\Parse\RangeParser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use ptlis\SemanticVersion\Comparator\ComparatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use ptlis\SemanticVersion\Parse\Token; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use ptlis\SemanticVersion\Parse\VersionParser; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use ptlis\SemanticVersion\Version\Version; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use ptlis\SemanticVersion\VersionRange\ComparatorVersion; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use ptlis\SemanticVersion\VersionRange\LogicalAnd; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * Trait implementing method to parse a simple range (branch, tilde and wildcard) after a normalisation step. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 23 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  | trait ParseSimpleRange | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      * Parse a simple version range | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      * @param VersionParser $versionParser | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      * @param ComparatorInterface $greaterOrEqualTo | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      * @param ComparatorInterface $lessThan | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |      * @param Token[] $lowerVersionTokenList | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |      * @return LogicalAnd | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 4 |  |     protected function parseSimpleVersionRange( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         VersionParser $versionParser, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         ComparatorInterface $greaterOrEqualTo, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         ComparatorInterface $lessThan, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         array $lowerVersionTokenList | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 4 |  |         $lowerVersion = $versionParser->parse($lowerVersionTokenList); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         // Upto minor version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 4 |  |         if (count($lowerVersionTokenList) > 3) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 3 |  |             $upperVersion = new Version($lowerVersion->getMajor(), $lowerVersion->getMinor() + 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         // Upto patch version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 1 |  |             $upperVersion = new Version($lowerVersion->getMajor() + 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 4 |  |         return new LogicalAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 4 |  |             new ComparatorVersion($greaterOrEqualTo, $lowerVersion), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 4 |  |             new ComparatorVersion($lessThan, $upperVersion) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         ); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 58 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 59 |  |  |  | 
            
                        
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.