| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\Composer; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class ComposerInstalled { |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
private $contents; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public function __construct( $location ) { |
| 21 |
$this->contents = json_decode( file_get_contents( $location ), true ); |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 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 |
} |