1 | <?php |
||
34 | class PackageConverter |
||
35 | { |
||
36 | /** |
||
37 | * The root package of the installation. |
||
38 | * |
||
39 | * @var RootPackageInterface |
||
40 | */ |
||
41 | private $rootPackage; |
||
42 | |||
43 | /** |
||
44 | * Create a new instance. |
||
45 | * |
||
46 | * @param RootPackageInterface $rootPackage The root package of the installation. |
||
47 | */ |
||
48 | public function __construct(RootPackageInterface $rootPackage) |
||
52 | |||
53 | /** |
||
54 | * Create a new instance and return it. |
||
55 | * |
||
56 | * @param RootPackageInterface $rootPackage The root package of the installation. |
||
57 | * |
||
58 | * @return PackageConverter |
||
59 | */ |
||
60 | public static function create(RootPackageInterface $rootPackage) |
||
64 | |||
65 | /** |
||
66 | * Convert a package version into string representation. |
||
67 | * |
||
68 | * @param PackageInterface $package The package to extract the version from. |
||
69 | * |
||
70 | * @param bool $fullReference Flag if the complete reference shall be added or an abbreviated form. |
||
71 | * |
||
72 | * @return string |
||
73 | * |
||
74 | * @throws \RuntimeException If the package is a dev package and does not have valid reference information. |
||
75 | */ |
||
76 | public static function convertPackageVersion(PackageInterface $package, $fullReference = false) |
||
92 | |||
93 | /** |
||
94 | * Convert a package to array information used by json API. |
||
95 | * |
||
96 | * @param PackageInterface $package The package to convert. |
||
97 | * |
||
98 | * @param null|string $upgradeVersion The package version to show as upgradable to. |
||
99 | * |
||
100 | * @return JsonArray |
||
101 | */ |
||
102 | public function convertPackageToArray(PackageInterface $package, $upgradeVersion = null) |
||
127 | |||
128 | /** |
||
129 | * Convert the information of all packages in a repository to an array used by json API. |
||
130 | * |
||
131 | * @param RepositoryInterface $repository The repository holding the packages to convert. |
||
132 | * |
||
133 | * @param bool $requiredOnly If true, return only the packages added to the root package as require. |
||
134 | * |
||
135 | * @param null|JsonArray $upgradeList The package version to show as upgradable to. |
||
136 | * |
||
137 | * @return JsonArray |
||
138 | */ |
||
139 | public function convertRepositoryToArray( |
||
164 | |||
165 | /** |
||
166 | * Compare two packages by their names. |
||
167 | * |
||
168 | * @param array $left The first package for comparison. |
||
169 | * |
||
170 | * @param array $right The second package for comparison. |
||
171 | * |
||
172 | * @return int |
||
173 | * |
||
174 | * @internal |
||
175 | */ |
||
176 | public function packageCompare($left, $right) |
||
180 | |||
181 | /** |
||
182 | * Check if a package is locked. |
||
183 | * |
||
184 | * @param string $packageName The name of the package to test. |
||
185 | * |
||
186 | * @return bool |
||
187 | * |
||
188 | * @see ComposerJson::isLocked() |
||
189 | */ |
||
190 | private function isLocked($packageName) |
||
195 | |||
196 | /** |
||
197 | * Determine the constraint defined for a given package (if required via root project). |
||
198 | * |
||
199 | * @param string $packageName The name of the package to retrieve the constraint for. |
||
200 | * |
||
201 | * @return string|null |
||
202 | */ |
||
203 | private function getConstraint($packageName) |
||
221 | |||
222 | /** |
||
223 | * Convert the data of a complete package to the passed json array. |
||
224 | * |
||
225 | * @param CompletePackageInterface $package The package to process. |
||
226 | * |
||
227 | * @param JsonArray $data The json array to push the data to. |
||
228 | * |
||
229 | * @return void |
||
230 | */ |
||
231 | private function convertCompletePackage(CompletePackageInterface $package, $data) |
||
255 | } |
||
256 |