src/Composer/Search/RepositorySearch.php
protected function decorateWithPackagistStats(VersionedPackage $package)
    {
        if (null === $this->decorateBaseUrl) {
            return $package;
        }

        $rfs        = new RemoteFilesystem(new BufferIO());
        $requestUrl = sprintf($this->decorateBaseUrl, $package->getName());
        if (!($jsonData = $rfs->getContents($requestUrl, $requestUrl))) {
            $this->decorateBaseUrl = null;
            return $package;
        }
        try {
            $data = new JsonArray($jsonData);
        } catch (\RuntimeException $exception) {
            $this->decorateBaseUrl = null;
            return  $package;
        }

        $metaPaths = [
            'downloads' => 'package/downloads/total',
            'favers'    => 'package/favers'
        ];

        foreach ($metaPaths as $metaKey => $metaPath) {
            $package->addMetaData($metaKey, $data->get($metaPath));
        }

        return $package;
    }
protected function decorateWithPackagistStats(VersionedPackage $package)
    {
        if (null === $this->decorateBaseUrl) {
            return $package;
        }

        $rfs        = new RemoteFilesystem(new BufferIO());
        $requestUrl = sprintf($this->decorateBaseUrl, $package->getName());
        if (!($jsonData = $rfs->getContents($requestUrl, $requestUrl))) {
            $this->decorateBaseUrl = null;
            return $package;
        }
        try {
            $data = new JsonArray($jsonData);
        } catch (\RuntimeException $exception) {
            $this->decorateBaseUrl = null;
            return  $package;
        }

        $metaPaths = [
            'downloads' => 'package/downloads/total',
            'favers'    => 'package/favers'
        ];

        foreach ($metaPaths as $metaKey => $metaPath) {
            $package->addMetaData($metaKey, $data->get($metaPath));
        }

        return $package;
    }
protected function decorateWithPackagistStats ( VersionedPackage $ package ) { if ( null === $ this -> decorateBaseUrl ) { return $ package ; } $ rfs = new RemoteFilesystem ( new BufferIO ( ) ) ; $ requestUrl = sprintf ( $ this -> decorateBaseUrl , $ package -> getName ( ) ) ; if ( ! ( $ jsonData = $ rfs -> getContents ( $ requestUrl , $ requestUrl ) ) ) { $ this -> decorateBaseUrl = null ; return $ package ; } try { $ data = new JsonArray ( $ jsonData ) ; } catch ( \ RuntimeException $ exception ) { $ this -> decorateBaseUrl = null ; return $ package ; } $ metaPaths = [ 'downloads' => 'package/downloads/total' , 'favers' => 'package/favers' ] ; foreach ( $ metaPaths as $ metaKey => $ metaPath ) { $ package -> addMetaData ( $ metaKey , $ data -> get ( $ metaPath ) ) ; } return $ package ; }
Decorate the package with stats from packagist.

@param VersionedPackage $package The package version.

@return VersionedPackage
Decorate the package with stats from packagist .