vanbrabantf / npm-stat-fetcher
A small package that returns some common stats about npm packages
Requires
- php: ^7.0
- cakephp/chronos: ^1.1
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^6.3
This package is not auto-updated.
Last update: 2024-04-19 05:26:21 UTC
README
Purpose
A simple package written in PHP that fetches statistics from NPM. It's mostly a wrapper around the NPM-API.
Installation
Installation can be done easily through composer.
composer require vanbrabantf/npm-stat-fetcher
Usage
tl;dr: Usage of the package is pretty simple, just pass the name of the npm
package you would like to get the stats off to the methods inside of the StatFetcher
class.
You can import the class like this:
$statFetcher = new Vanbrabantf\NpmStatFetcher\StatFetcher();
Available methods
Will return the downloads of the previous day:
$statFetcher->getDownloadsLastDay('jquery');
Will return the downloads of the previous week:
$statFetcher->getDownloadsLastWeek('jquery');
Will return the downloads of the previous month:
$statFetcher->getDownloadsLastMonth('jquery');
Will return the downloads of the previous year:
$statFetcher->getDownloadsLastYear('jquery');
Will return the total downloads:
$statFetcher->getDownloads('jquery');
Will return the total downloads between 2 dates:
$start = new DateTime('1989-12-13'); $end = new DateTime('1988-11-07'); $statFetcher->getDownloadsBetweenDates('jquery', $start, $end);
What it will return
The methods will return DownloadStatistics
objects. These are value objects that have values for the dates, download counts and package information.