1 | <?php |
||
33 | class PackageConverter |
||
34 | { |
||
35 | /** |
||
36 | * The root package of the installation. |
||
37 | * |
||
38 | * @var RootPackageInterface |
||
39 | */ |
||
40 | private $rootPackage; |
||
41 | |||
42 | /** |
||
43 | * Create a new instance. |
||
44 | * |
||
45 | * @param RootPackageInterface $rootPackage The root package of the installation. |
||
46 | */ |
||
47 | public function __construct(RootPackageInterface $rootPackage) |
||
51 | |||
52 | /** |
||
53 | * Create a new instance and return it. |
||
54 | * |
||
55 | * @param RootPackageInterface $rootPackage The root package of the installation. |
||
56 | * |
||
57 | * @return PackageConverter |
||
58 | */ |
||
59 | public static function create(RootPackageInterface $rootPackage) |
||
63 | |||
64 | /** |
||
65 | * Convert a package version into string representation. |
||
66 | * |
||
67 | * @param PackageInterface $package The package to extract the version from. |
||
68 | * |
||
69 | * @param bool $fullReference Flag if the complete reference shall be added or an abbreviated form. |
||
70 | * |
||
71 | * @return string |
||
72 | * |
||
73 | * @throws \RuntimeException If the package is a dev package and does not have valid reference information. |
||
74 | */ |
||
75 | public static function convertPackageVersion(PackageInterface $package, $fullReference = false) |
||
91 | |||
92 | /** |
||
93 | * Convert a package to array information used by json API. |
||
94 | * |
||
95 | * @param PackageInterface $package The package to convert. |
||
96 | * |
||
97 | * @param null|string $upgradeVersion The package version to show as upgradable to. |
||
98 | * |
||
99 | * @return JsonArray |
||
100 | */ |
||
101 | public function convertPackageToArray(PackageInterface $package, $upgradeVersion = null) |
||
143 | |||
144 | /** |
||
145 | * Convert the information of all packages in a repository to an array used by json API. |
||
146 | * |
||
147 | * @param RepositoryInterface $repository The repository holding the packages to convert. |
||
148 | * |
||
149 | * @param bool $requiredOnly If true, return only the packages added to the root package as require. |
||
150 | * |
||
151 | * @param null|JsonArray $upgradeList The package version to show as upgradable to. |
||
152 | * |
||
153 | * @return JsonArray |
||
154 | */ |
||
155 | public function convertRepositoryToArray( |
||
180 | |||
181 | /** |
||
182 | * Compare two packages by their names. |
||
183 | * |
||
184 | * @param array $left The first package for comparison. |
||
185 | * |
||
186 | * @param array $right The second package for comparison. |
||
187 | * |
||
188 | * @return int |
||
189 | * |
||
190 | * @internal |
||
191 | */ |
||
192 | public function packageCompare($left, $right) |
||
196 | |||
197 | /** |
||
198 | * Check if a package is locked. |
||
199 | * |
||
200 | * @param string $packageName The name of the package to test. |
||
201 | * |
||
202 | * @return bool |
||
203 | * |
||
204 | * @see ComposerJson::isLocked() |
||
205 | */ |
||
206 | private function isLocked($packageName) |
||
211 | |||
212 | /** |
||
213 | * Determine the constraint defined for a given package (if required via root project). |
||
214 | * |
||
215 | * @param string $packageName The name of the package to retrieve the constraint for. |
||
216 | * |
||
217 | * @return string|null |
||
218 | */ |
||
219 | private function getConstraint($packageName) |
||
237 | } |
||
238 |