Skip to content

Commit 083d361

Browse files
authored
Merge pull request #2 from adevade/add-support-for-php8
Add support for PHP 8.0
2 parents 3f072e3 + 459e2e9 commit 083d361

6 files changed

Lines changed: 78 additions & 67 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
php-version: ["7.2", "7.3", "7.4"]
12+
php-version: ["7.2", "7.3", "7.4", "8.0"]
1313

1414
steps:
1515
- name: Checkout

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## 2.1.0 - 2021-04-16
8+
9+
### Added
10+
11+
- Support PHP 8.0.
12+
13+
### Changed
14+
15+
- Exception messages use correct variable names.
16+
717
## 2.0.0 - 2020-04-17
818

919
:boom: Breaking changes! New namespace. Run `composer dump-autoload` after update.

README.md

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
1-
# Seconds
2-
3-
[![Tests](https://github.com/adevade/seconds/workflows/Tests/badge.svg)](https://github.com/adevade/seconds)
4-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/adevade/seconds.svg)](https://packagist.org/packages/adevade/seconds)
5-
[![Total Downloads](https://img.shields.io/packagist/dt/adevade/seconds.svg)](https://packagist.org/packages/adevade/seconds)
6-
7-
Helpers for converting time to seconds.
8-
9-
## Installation
10-
11-
You can install the package via composer:
12-
13-
```bash
14-
composer require adevade/seconds
15-
```
16-
17-
## Usage
18-
19-
```php
20-
use Adevade\Seconds;
21-
22-
Seconds::fromMinutes(2); // returns => (int) 120
23-
```
24-
25-
### Available methods
26-
27-
```php
28-
Seconds::fromMinutes($minutes = 5);
29-
Seconds::fromHours($hours = 12);
30-
Seconds::fromDays($days = 4);
31-
Seconds::fromWeeks($weeks = 2);
32-
Seconds::fromMonths($months = 6);
33-
Seconds::fromYears($years = 2);
34-
35-
Seconds::fromMinute();
36-
Seconds::fromHour();
37-
Seconds::fromDay();
38-
Seconds::fromWeek();
39-
Seconds::fromMonth();
40-
Seconds::fromYear();
41-
```
42-
43-
### Available constants
44-
45-
```php
46-
Seconds::MINUTE;
47-
Seconds::HOUR;
48-
Seconds::DAY;
49-
Seconds::WEEK;
50-
Seconds::MONTH;
51-
Seconds::YEAR;
52-
```
53-
54-
> Months have an average length of 30.42 days.\
55-
> Years have an average length of 365.24 days.
56-
57-
## Credits
58-
59-
- [Andréas Lundgren](https://github.com/adevade)
60-
61-
Idea came from [this tweet by @LasseRafn](https://twitter.com/LasseRafn/status/1225017098373685255). Thanks!
1+
# Seconds
2+
3+
[![Tests](https://github.com/adevade/seconds/workflows/Tests/badge.svg)](https://github.com/adevade/seconds)
4+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/adevade/seconds.svg)](https://packagist.org/packages/adevade/seconds)
5+
[![Total Downloads](https://img.shields.io/packagist/dt/adevade/seconds.svg)](https://packagist.org/packages/adevade/seconds)
6+
7+
Helpers for converting time to seconds.
8+
9+
## Installation
10+
11+
You can install the package via composer:
12+
13+
```bash
14+
composer require adevade/seconds
15+
```
16+
17+
## Usage
18+
19+
```php
20+
use Adevade\Seconds;
21+
22+
Seconds::fromMinutes(2); // returns => (int) 120
23+
```
24+
25+
### Available methods
26+
27+
```php
28+
Seconds::fromMinutes($minutes = 5);
29+
Seconds::fromHours($hours = 12);
30+
Seconds::fromDays($days = 4);
31+
Seconds::fromWeeks($weeks = 2);
32+
Seconds::fromMonths($months = 6);
33+
Seconds::fromYears($years = 2);
34+
35+
Seconds::fromMinute();
36+
Seconds::fromHour();
37+
Seconds::fromDay();
38+
Seconds::fromWeek();
39+
Seconds::fromMonth();
40+
Seconds::fromYear();
41+
```
42+
43+
### Available constants
44+
45+
```php
46+
Seconds::MINUTE;
47+
Seconds::HOUR;
48+
Seconds::DAY;
49+
Seconds::WEEK;
50+
Seconds::MONTH;
51+
Seconds::YEAR;
52+
```
53+
54+
> Months have an average length of 30.42 days.\
55+
> Years have an average length of 365.24 days.
56+
57+
## Credits
58+
59+
- [Andréas Lundgren](https://github.com/adevade)
60+
61+
Idea came from [this tweet by @LasseRafn](https://twitter.com/LasseRafn/status/1225017098373685255). Thanks!

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^7.2"
21+
"php": "^7.2|^8.0"
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^8.0|^9.0"

src/Seconds.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public static function __callStatic($method, $parameters)
4646
if (!isset($parameters[0]) || !is_int($parameters[0])) {
4747
throw new InvalidArgumentException(
4848
sprintf(
49-
'%s::%s(int $seconds) expects an integer.',
49+
'%s::%s(int $%s) expects an integer.',
5050
static::class,
51-
$method
51+
$method,
52+
str_replace('from', '', strtolower($method))
5253
)
5354
);
5455
}

tests/SecondsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function it_throws_an_exception_if_no_parameter_is_given()
8080
{
8181
$this->expectException(InvalidArgumentException::class);
8282
$this->expectExceptionMessage(
83-
'Adevade\Seconds::fromMinutes(int $seconds) expects an integer.'
83+
'Adevade\Seconds::fromMinutes(int $minutes) expects an integer.'
8484
);
8585

8686
Seconds::fromMinutes();
@@ -91,7 +91,7 @@ function it_throws_an_exception_if_parameter_is_not_an_integer()
9191
{
9292
$this->expectException(InvalidArgumentException::class);
9393
$this->expectExceptionMessage(
94-
'Adevade\Seconds::fromDays(int $seconds) expects an integer.'
94+
'Adevade\Seconds::fromDays(int $days) expects an integer.'
9595
);
9696

9797
Seconds::fromDays('4');

0 commit comments

Comments
 (0)