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