Skip to content

Commit 4ec0141

Browse files
authored
v4.0 (#11)
* Install and run Laravel Pint formatter * Update GH Actions dependencies * Update tests.yml * Add GH Action for code formatting * Update composer.json * Update CHANGELOG.md
1 parent 48a1c63 commit 4ec0141

File tree

6 files changed

+82
-31
lines changed

6 files changed

+82
-31
lines changed

.github/workflows/formatting.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Formatting
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
formatting:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: "8.1"
18+
tools: composer:v2
19+
coverage: none
20+
21+
- name: Install dependencies
22+
run: composer update --prefer-dist --no-interaction --no-progress
23+
24+
- name: Check code formatting
25+
run: ./vendor/bin/pint --test -v

.github/workflows/tests.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
name: Tests
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
48

59
jobs:
6-
run:
7-
name: PHP ${{ matrix.php-version }}
10+
tests:
11+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
812

913
runs-on: ubuntu-latest
14+
1015
strategy:
16+
fail-fast: true
1117
matrix:
12-
php-version: ["8.0", "8.1"]
18+
php: ["8.0", "8.1"]
19+
stability: [prefer-lowest, prefer-stable]
20+
include:
21+
- php: "8.2"
22+
stability: prefer-stable --ignore-platform-req=php+
1323

1424
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v2
25+
- name: Checkout code
26+
uses: actions/checkout@v3
1727

1828
- name: Setup PHP
1929
uses: shivammathur/setup-php@v2
2030
with:
21-
php-version: ${{ matrix.php-version }}
31+
php-version: ${{ matrix.php }}
32+
ini-values: error_reporting=E_ALL
33+
tools: composer:v2
2234
coverage: none
2335

24-
- name: Get Composer cache directory
25-
id: composer-cache
26-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
27-
28-
- name: Cache dependencies
29-
uses: actions/cache@v1
30-
with:
31-
path: ${{ steps.composer-cache.outputs.dir }}
32-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
33-
restore-keys: ${{ runner.os }}-composer-
34-
35-
- name: Install Composer dependencies
36-
run: composer install
36+
- name: Install dependencies
37+
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
3738

38-
- name: Run PHPUnit
39-
run: ./vendor/bin/phpunit
39+
- name: Execute tests
40+
run: ./vendor/bin/phpunit --verbose

CHANGELOG.md

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

55
## [Unreleased]
66

7-
## 3.0.0 - 2021-10-25
7+
## [4.0.0] - 2022-10-03
8+
9+
### Removed
10+
11+
- Drop support for PHP 7.
12+
13+
## [3.0.0] - 2021-10-25
814

915
### Removed
1016

1117
- Drop support for PHP <= 7.3.
1218
- Drop support for PHPUnit 8.
1319

14-
## 2.1.0 - 2021-04-16
20+
## [2.1.0] - 2021-04-16
1521

1622
### Added
1723

@@ -21,15 +27,15 @@ All notable changes to this project will be documented in this file.
2127

2228
- Exception messages use correct variable names.
2329

24-
## 2.0.0 - 2020-04-17
30+
## [2.0.0] - 2020-04-17
2531

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

2834
### Changed
2935

3036
- Change namespace to top level `Adevade`. Use `Adevade\Seconds::class` instead of `Adevade\Seconds\Seconds::class` in ^2.0.
3137

32-
## 1.1.0 - 2020-04-17
38+
## [1.1.0] - 2020-04-17
3339

3440
### Added
3541

@@ -55,7 +61,12 @@ All notable changes to this project will be documented in this file.
5561

5662
- Initial release
5763

58-
[unreleased]: https://github.com/adevade/seconds/compare/1.0.2...HEAD
64+
[unreleased]: https://github.com/adevade/seconds/compare/4.0.0...HEAD
65+
[4.0.0]: https://github.com/adevade/seconds/compare/3.0.0...4.0.0
66+
[3.0.0]: https://github.com/adevade/seconds/compare/2.1.0...3.0.0
67+
[2.1.0]: https://github.com/adevade/seconds/compare/2.0.0...2.1.0
68+
[2.0.0]: https://github.com/adevade/seconds/compare/1.1.0...2.0.0
69+
[1.1.0]: https://github.com/adevade/seconds/compare/1.0.2...1.1.0
5970
[1.0.2]: https://github.com/adevade/seconds/compare/1.0.1...1.0.2
6071
[1.0.1]: https://github.com/adevade/seconds/compare/1.0.0...1.0.1
6172
[1.0.0]: https://github.com/adevade/seconds/releases/tag/1.0.0

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"php": "^8.0"
2222
},
2323
"require-dev": {
24+
"laravel/pint": "^1.2",
2425
"phpunit/phpunit": "^9.0"
2526
},
2627
"autoload": {
@@ -34,9 +35,12 @@
3435
}
3536
},
3637
"scripts": {
38+
"format": "vendor/bin/pint",
3739
"test": "vendor/bin/phpunit"
3840
},
3941
"config": {
4042
"sort-packages": true
41-
}
43+
},
44+
"minimum-stability": "dev",
45+
"prefer-stable": true
4246
}

pint.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"exclude": [
3+
"tests/"
4+
]
5+
}

src/Seconds.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@
2222
class Seconds
2323
{
2424
public const MINUTE = 60;
25+
2526
public const HOUR = 3600;
27+
2628
public const DAY = 86400;
29+
2730
public const WEEK = 604800;
31+
2832
public const MONTH = 2628288; // 30.42 days
33+
2934
public const YEAR = 31556736; // 365.24 days
3035

3136
/**
@@ -39,7 +44,7 @@ public static function __callStatic(string $method, array $parameters): int
3944
return static::getConstantFromMethodName($method);
4045
}
4146

42-
if (!isset($parameters[0]) || !is_int($parameters[0])) {
47+
if (! isset($parameters[0]) || ! is_int($parameters[0])) {
4348
throw new InvalidArgumentException(
4449
sprintf(
4550
'%s::%s(int $%s) expects an integer.',
@@ -58,7 +63,7 @@ public static function __callStatic(string $method, array $parameters): int
5863
*/
5964
protected static function isSingular(string $method): bool
6065
{
61-
return !preg_match('/s$/', $method);
66+
return ! preg_match('/s$/', $method);
6267
}
6368

6469
/**
@@ -72,7 +77,7 @@ protected static function getConstantFromMethodName(string $method): int
7277
$constant = preg_replace('/s$/', '', $constant);
7378
$constant = strtoupper($constant);
7479

75-
if (!defined("static::{$constant}")) {
80+
if (! defined("static::{$constant}")) {
7681
throw new BadMethodCallException(
7782
sprintf('%s::%s() does not exist.', static::class, $method)
7883
);

0 commit comments

Comments
 (0)