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;
    }