Merge "FauxRequest: don’t override getValues()"
[lhc/web/wiklou.git] / includes / libs / composer / ComposerInstalled.php
1 <?php
2
3 /**
4 * Reads an installed.json file and provides accessors to get what is
5 * installed
6 *
7 * @since 1.27
8 */
9 class ComposerInstalled {
10 /**
11 * @var array[]
12 */
13 private $contents;
14
15 /**
16 * @param string $location
17 */
18 public function __construct( $location ) {
19 $this->contents = json_decode( file_get_contents( $location ), true );
20 }
21
22 /**
23 * Dependencies currently installed according to installed.json
24 *
25 * @return array[]
26 */
27 public function getInstalledDependencies() {
28 $deps = [];
29 foreach ( $this->contents as $installed ) {
30 $deps[$installed['name']] = [
31 'version' => ComposerJson::normalizeVersion( $installed['version'] ),
32 'type' => $installed['type'],
33 'licenses' => $installed['license'] ?? [],
34 'authors' => $installed['authors'] ?? [],
35 'description' => $installed['description'] ?? '',
36 ];
37 }
38
39 ksort( $deps );
40 return $deps;
41 }
42 }