Debian Codegraph @

includes/libs/composer/ComposerInstalled.php

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