wiki.techinc.nl/includes/libs/composer/ComposerInstalled.php
Daimona Eaytoy ffec2d6ef7 libs: Declare dynamic properties and improve doc types
Change-Id: I5cf39d3dde5990e6a0fde91b98cf692e39a3a431
2019-09-12 10:57:26 +00:00

42 lines
892 B
PHP

<?php
/**
* Reads an installed.json file and provides accessors to get what is
* installed
*
* @since 1.27
*/
class ComposerInstalled {
/**
* @var array[]
*/
private $contents;
/**
* @param string $location
*/
public function __construct( $location ) {
$this->contents = json_decode( file_get_contents( $location ), true );
}
/**
* Dependencies currently installed according to installed.json
*
* @return array[]
*/
public function getInstalledDependencies() {
$deps = [];
foreach ( $this->contents as $installed ) {
$deps[$installed['name']] = [
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
'type' => $installed['type'],
'licenses' => $installed['license'] ?? [],
'authors' => $installed['authors'] ?? [],
'description' => $installed['description'] ?? '',
];
}
ksort( $deps );
return $deps;
}
}