Skip to content

Commit

Permalink
Merge 31738a5 into a615327
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed Sep 10, 2020
2 parents a615327 + 31738a5 commit d7432af
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: php

php:
- 7.0

- 7.2
env:
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `npm-stats-api` will be documented in this file

## 2.0.0 - 2020-09-10

- Require PHP >= 7.2
- Require Guzzle >= 7.0
- Fix yearly range that resulted in a 400 request sometimes

## 1.0.3 - 2020-09-10

- Add support for Guzzle 7
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
}
],
"require": {
"php": "^7.0",
"guzzlehttp/guzzle": "^6.3|^7.0"
"php": "^7.2",
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0"
"phpunit/phpunit": "^8.0.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/NpmStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function replaceSpecialPeriodsIfApplicable(&$period)
$period = "2015-01-01:{$currentDate}";
} else if ($period === self::LAST_YEAR) {
$currentDate = (new \DateTime)->format("Y-m-d");
$beforeDate = (new \DateTime)->modify("-1 year")->format("Y-m-d");
$beforeDate = (new \DateTime)->modify("-365 days")->format("Y-m-d");
$period = "{$beforeDate}:{$currentDate}";
}

Expand Down
4 changes: 2 additions & 2 deletions tests/NpmStatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NpmStatsTest extends TestCase
/** @var \Developmint\NpmStats\NpmStats */
protected $npmStats;

public function setUp()
public function setUp() : void
{
$client = new Client();

Expand Down Expand Up @@ -63,7 +63,7 @@ public function testItCanRetrieveYearlyStats()
$result = $this->npmStats->getStats($packageName, NpmStats::LAST_YEAR);
$this->assertArrayHasKey('start', $result);
$this->assertArrayHasKey('end', $result);
$this->assertEquals((new \DateTime)->modify("-1 year")->format("Y-m-d"), $result["start"]);
$this->assertEquals((new \DateTime)->modify("-365 days")->format("Y-m-d"), $result["start"]);

$this->assertEquals($packageName, $result["package"]);
$this->assertArrayHasKey('downloads', $result);
Expand Down

0 comments on commit d7432af

Please sign in to comment.