1 | <?php |
||
20 | class StabilityFlags |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var array Current package name => stability mappings |
||
25 | */ |
||
26 | protected $stabilityFlags; |
||
27 | |||
28 | /** |
||
29 | * @var int Current default minimum stability |
||
30 | */ |
||
31 | protected $minimumStability; |
||
32 | |||
33 | /** |
||
34 | * @var string Regex to extract an explict stability flag (eg '@dev') |
||
35 | */ |
||
36 | protected $explicitStabilityRe; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * @param array $stabilityFlags Current package name => stability mappings |
||
41 | * @param int $minimumStability Current default minimum stability |
||
42 | */ |
||
43 | 150 | public function __construct( |
|
53 | |||
54 | /** |
||
55 | * Get the stability value for a given string. |
||
56 | * |
||
57 | * @param string $name Stability name |
||
58 | * @return int Stability value |
||
59 | */ |
||
60 | 150 | protected function getStabilityInt($name) |
|
67 | |||
68 | /** |
||
69 | * Extract and merge stability flags from the given collection of |
||
70 | * requires with another collection of stability flags. |
||
71 | * |
||
72 | * @param array $requires New package name => link mappings |
||
73 | * @return array Unified package name => stability mappings |
||
74 | */ |
||
75 | 150 | public function extractAll(array $requires) |
|
97 | |||
98 | |||
99 | /** |
||
100 | * Extract the most unstable explicit stability (eg '@dev') from a version |
||
101 | * specification. |
||
102 | * |
||
103 | * @param string $version |
||
104 | * @return int|null Stability or null if no explict stability found |
||
105 | */ |
||
106 | 150 | protected function getExplicitStability($version) |
|
118 | |||
119 | |||
120 | /** |
||
121 | * Split a version specification into a list of version constraints. |
||
122 | * |
||
123 | * @param string $version |
||
124 | * @return array |
||
125 | */ |
||
126 | 150 | protected function splitConstraints($version) |
|
127 | { |
||
128 | 150 | $found = array(); |
|
129 | 150 | $orConstraints = preg_split('/\s*\|\|?\s*/', trim($version)); |
|
130 | 150 | foreach ($orConstraints as $constraints) { |
|
131 | 150 | $andConstraints = preg_split( |
|
132 | 150 | '/(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)/', |
|
133 | 60 | $constraints |
|
134 | 30 | ); |
|
135 | 150 | foreach ($andConstraints as $constraint) { |
|
136 | 150 | $found[] = $constraint; |
|
137 | 30 | } |
|
138 | 30 | } |
|
139 | 150 | return $found; |
|
140 | } |
||
141 | |||
142 | |||
143 | /** |
||
144 | * Get the stability of a version |
||
145 | * |
||
146 | * @param string $version |
||
147 | * @return int|null Stability or null if STABLE or less than minimum |
||
148 | */ |
||
149 | 110 | protected function getParsedStability($version) |
|
167 | |||
168 | |||
169 | /** |
||
170 | * Get the current stability of a given package. |
||
171 | * |
||
172 | * @param string $name |
||
173 | * @return int|null Stability of null if not set |
||
174 | */ |
||
175 | 150 | protected function getCurrentStability($name) |
|
180 | } |
||
181 | // vim:sw=4:ts=4:sts=4:et: |
||
182 |