4 * Reads a composer.json file and provides accessors to get
5 * its hash and the required dependencies
16 * @param string $location
18 public function __construct( $location ) {
19 $this->contents
= json_decode( file_get_contents( $location ), true );
23 * Dependencies as specified by composer.json
27 public function getRequiredDependencies() {
29 if ( isset( $this->contents
['require'] ) ) {
30 foreach ( $this->contents
['require'] as $package => $version ) {
31 if ( $package !== "php" && strpos( $package, 'ext-' ) !== 0 ) {
32 $deps[$package] = self
::normalizeVersion( $version );
41 * Strip a leading "v" from the version name
43 * @param string $version
46 public static function normalizeVersion( $version ) {
47 if ( strpos( $version, 'v' ) === 0 ) {
48 // Composer auto-strips the "v" in front of the tag name
49 $version = ltrim( $version, 'v' );