2014-12-08 20:08:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads a composer.lock file and provides accessors to get
|
|
|
|
|
* its hash and what is installed
|
|
|
|
|
*
|
|
|
|
|
* @since 1.25
|
|
|
|
|
*/
|
|
|
|
|
class ComposerLock {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $location
|
|
|
|
|
*/
|
|
|
|
|
public function __construct( $location ) {
|
|
|
|
|
$this->contents = json_decode( file_get_contents( $location ), true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dependencies currently installed according to composer.lock
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getInstalledDependencies() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$deps = [];
|
2014-12-08 20:08:52 +00:00
|
|
|
foreach ( $this->contents['packages'] as $installed ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$deps[$installed['name']] = [
|
2015-01-03 23:28:02 +00:00
|
|
|
'version' => ComposerJson::normalizeVersion( $installed['version'] ),
|
|
|
|
|
'type' => $installed['type'],
|
2016-02-17 09:09:32 +00:00
|
|
|
'licenses' => isset( $installed['license'] ) ? $installed['license'] : [],
|
|
|
|
|
'authors' => isset( $installed['authors'] ) ? $installed['authors'] : [],
|
2017-08-11 13:53:17 +00:00
|
|
|
'description' => isset( $installed['description'] ) ? $installed['description'] : '',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2014-12-08 20:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $deps;
|
|
|
|
|
}
|
|
|
|
|
}
|