1 | <?php |
||
20 | final class VersionRangeParser |
||
21 | { |
||
22 | /** @var LogicalOperatorProcessor */ |
||
23 | private $logicalOperatorProcessor; |
||
24 | |||
25 | /** @var RangeParserInterface[] */ |
||
26 | private $rangeParserList; |
||
27 | |||
28 | /** @var string[] Array of tokens representing logical operators */ |
||
29 | private $operatorTokenList = [ |
||
30 | Token::LOGICAL_AND, |
||
31 | Token::LOGICAL_OR |
||
32 | ]; |
||
33 | |||
34 | |||
35 | /** |
||
36 | * Constructor |
||
37 | * |
||
38 | * @param LogicalOperatorProcessor $logicalOperatorProcessor |
||
39 | */ |
||
40 | 32 | public function __construct( |
|
47 | |||
48 | /** |
||
49 | * Parse a version range. |
||
50 | * |
||
51 | * @param Token[] $tokenList |
||
52 | * |
||
53 | * @return VersionRangeInterface |
||
54 | */ |
||
55 | 32 | public function parseRange(array $tokenList) |
|
75 | |||
76 | /** |
||
77 | * Attempt to parse the token list as a version range into an object implementing VersionRangeInterface |
||
78 | * |
||
79 | * Iterates through the provided range parsers checking to see if they can parse the token list. If they can then we |
||
80 | * call the parse method and return a version range object, otherwise return null. |
||
81 | * |
||
82 | * @param Token[] $tokenList |
||
83 | * |
||
84 | * @return VersionRangeInterface|null |
||
85 | */ |
||
86 | 32 | private function attemptParse(array $tokenList) |
|
98 | |||
99 | /** |
||
100 | * Clusters the tokens, breaking them up upon finding a logical AND / OR. |
||
101 | * |
||
102 | * @param Token[] $tokenList |
||
103 | * |
||
104 | * @return Token[][] $tokenList |
||
105 | */ |
||
106 | 32 | private function clusterTokens(array $tokenList) |
|
138 | } |
||
139 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.