src/Reader.php
protected function readFromSource(array $source, string $package) : ?string
    {
        // Abort if no name property
        if(!isset($source['name'])){
            return null;
        }

        // Abort if name is not the same a package name
        if($source['name'] != $package){
            return null;
        }

        // At this point it means that the package matches.
        // We check for a version property.
        if(isset($source['version'])){
            return $source['version'];
        }

        // This means that no version property existed - which
        // could mean that the source is an actual composer file.
        // Therefore, we check if there is an branch alias
        // specified. (dev-master assumed)
        if(isset($source['extra']['branch-alias']['dev-master'])){
            return $source['extra']['branch-alias']['dev-master'];
        }

        // Sadly, if reached here then there is no version available
        // nor a branch alias. Therefore, we can only return a default
        // version...
        return self::DEFAULT_VERSION;
    }
protected function readFromSource(array $source, string $package) : ?string
    {
        // Abort if no name property
        if(!isset($source['name'])){
            return null;
        }

        // Abort if name is not the same a package name
        if($source['name'] != $package){
            return null;
        }

        // At this point it means that the package matches.
        // We check for a version property.
        if(isset($source['version'])){
            return $source['version'];
        }

        // This means that no version property existed - which
        // could mean that the source is an actual composer file.
        // Therefore, we check if there is an branch alias
        // specified. (dev-master assumed)
        if(isset($source['extra']['branch-alias']['dev-master'])){
            return $source['extra']['branch-alias']['dev-master'];
        }

        // Sadly, if reached here then there is no version available
        // nor a branch alias. Therefore, we can only return a default
        // version...
        return self::DEFAULT_VERSION;
    }
protected function readFromSource ( array $ source , string $ package ) : ? string { // Abort if no name property if ( ! isset ( $ source [ 'name' ] ) ) { return null ; } // Abort if name is not the same a package name if ( $ source [ 'name' ] != $ package ) { return null ; } // At this point it means that the package matches. // We check for a version property. if ( isset ( $ source [ 'version' ] ) ) { return $ source [ 'version' ] ; } // This means that no version property existed - which // could mean that the source is an actual composer file. // Therefore, we check if there is an branch alias // specified. (dev-master assumed) if ( isset ( $ source [ 'extra' ] [ 'branch-alias' ] [ 'dev-master' ] ) ) { return $ source [ 'extra' ] [ 'branch-alias' ] [ 'dev-master' ] ; } // Sadly, if reached here then there is no version available // nor a branch alias. Therefore, we can only return a default // version... return self :: DEFAULT_VERSION ; }
Attempts to read a "version" property on the source
and return it.

@param array $source Composer file or installed package
@param string $package Name of package we are looking for

@return string|null Version or null if not found
Attempts to read a version property on the source and return it .