1 | <?php |
||
14 | final class Installer implements PluginInterface, EventSubscriberInterface |
||
15 | { |
||
16 | private static $generatedClassTemplate = <<<'PHP' |
||
17 | <?php |
||
18 | |||
19 | namespace PackageVersions; |
||
20 | |||
21 | /** |
||
22 | * This class is generated by ocramius/package-versions, specifically by |
||
23 | * @see \PackageVersions\Installer |
||
24 | * |
||
25 | * This file is overwritten at every run of `composer install` or `composer update`. |
||
26 | */ |
||
27 | final class Versions |
||
28 | { |
||
29 | const VERSIONS = %s; |
||
30 | |||
31 | private function __construct() |
||
32 | { |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @throws \OutOfBoundsException if a version cannot be located |
||
37 | */ |
||
38 | public static function getVersion(string $packageName) : string |
||
39 | { |
||
40 | if (! isset(self::VERSIONS[$packageName])) { |
||
41 | throw new \OutOfBoundsException( |
||
42 | 'Required package "' . $packageName . '" is not installed: cannot detect its version' |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | return self::VERSIONS[$packageName]; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | PHP; |
||
51 | |||
52 | /** |
||
53 | * {@inheritDoc} |
||
54 | */ |
||
55 | 1 | public function activate(Composer $composer, IOInterface $io) |
|
59 | |||
60 | /** |
||
61 | * {@inheritDoc} |
||
62 | */ |
||
63 | 1 | public static function getSubscribedEvents() |
|
70 | |||
71 | /** |
||
72 | * @param Event $composerEvent |
||
73 | * |
||
74 | * @return void |
||
75 | */ |
||
76 | 1 | public static function dumpVersionsClass(Event $composerEvent) |
|
90 | |||
91 | 1 | private static function generateVersionsClass(Composer $composer) : string |
|
98 | |||
99 | /** |
||
100 | * @param string $path |
||
101 | * @param string $versionClassSource |
||
102 | */ |
||
103 | private static function writeVersionClassToFile(string $path, string $versionClassSource) |
||
107 | 1 | ||
108 | private static function getVendorDir(Composer $composer) : string |
||
117 | 1 | ||
118 | 1 | /** |
|
119 | 1 | * @param Composer $composer |
|
120 | 1 | * |
|
121 | 1 | * @return void |
|
122 | 1 | */ |
|
123 | private static function reDumpAutoloader(Composer $composer) |
||
134 | 1 | ||
135 | /** |
||
136 | 1 | * @param Locker $locker |
|
137 | 1 | * @param RootPackageInterface $rootPackage |
|
138 | 1 | * |
|
139 | * @return \Generator|\string[] |
||
140 | */ |
||
141 | 1 | private static function getVersions(Locker $locker, RootPackageInterface $rootPackage) : \Generator |
|
152 | } |
||
153 |