Skip to content

Commit a06344a

Browse files
Merge pull request #24 from stevegrunwell/release/v2.0.2
Version 2.0.2
2 parents de474c5 + 20dd772 commit a06344a

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Version 2.0.2] — 2024-08-23
9+
10+
* Use the `const` keyword instead of `define()` for slight performance gains, easier readability, and better IDE interoperability. Props @ChadSikorra and @ramsey for the recommendation! ([#23])
11+
812
## [Version 2.0.1] — 2024-08-22
913

1014
* Now that constants are namespaced, remove the `defined()` checks and unnecessary multiplication in order to a) help IDEs and b) remove an (albeit tiny) level of overhead ([#21])
@@ -103,6 +107,7 @@ Initial public release of the library, with the following constants:
103107

104108

105109
[Unreleased]: https://github.com/stevegrunwell/time-constants/compare/main...develop
110+
[Version 2.0.2]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.2
106111
[Version 2.0.1]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.1
107112
[Version 2.0.0]: https://github.com/stevegrunwell/time-constants/releases/tag/v2.0.0
108113
[Version 1.2.0]: https://github.com/stevegrunwell/time-constants/releases/tag/v1.2.0
@@ -122,3 +127,4 @@ Initial public release of the library, with the following constants:
122127
[#18]: https://github.com/stevegrunwell/time-constants/pull/18
123128
[#19]: https://github.com/stevegrunwell/time-constants/pull/19
124129
[#21]: https://github.com/stevegrunwell/time-constants/pull/21
130+
[#23]: https://github.com/stevegrunwell/time-constants/pull/23

src/Constants.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Defines useful time-based constants.
55
*
6-
* @package SteveGrunwell\TimeConstants
6+
* @package TimeConstants
77
*/
88

99
declare(strict_types=1);
@@ -22,37 +22,37 @@
2222
/**
2323
* One second.
2424
*/
25-
define(__NAMESPACE__ . '\\ONE_SECOND', 1);
25+
const ONE_SECOND = 1;
2626

2727
/**
2828
* One minute is 60 seconds.
2929
*/
30-
define(__NAMESPACE__ . '\\MINUTE_IN_SECONDS', 60);
30+
const MINUTE_IN_SECONDS = 60;
3131

3232
/**
3333
* One hour is 60 minutes.
3434
*/
35-
define(__NAMESPACE__ . '\\HOUR_IN_SECONDS', 3600);
35+
const HOUR_IN_SECONDS = 3600;
3636

3737
/**
3838
* One day is 24 hours.
3939
*/
40-
define(__NAMESPACE__ . '\\DAY_IN_SECONDS', 86400);
40+
const DAY_IN_SECONDS = 86400;
4141

4242
/**
4343
* One week is 7 days.
4444
*/
45-
define(__NAMESPACE__ . '\\WEEK_IN_SECONDS', 604800);
45+
const WEEK_IN_SECONDS = 604800;
4646

4747
/**
4848
* For general purposes, assume that one month is 30 days.
4949
*/
50-
define(__NAMESPACE__ . '\\MONTH_IN_SECONDS', 2592000);
50+
const MONTH_IN_SECONDS = 2592000;
5151

5252
/**
5353
* For general purposes, assume that one year is 365 days.
5454
*/
55-
define(__NAMESPACE__ . '\\YEAR_IN_SECONDS', 31536000);
55+
const YEAR_IN_SECONDS = 31536000;
5656

5757
/**
5858
* Time based in minutes.
@@ -64,32 +64,32 @@
6464
/**
6565
* One minute.
6666
*/
67-
define(__NAMESPACE__ . '\\ONE_MINUTE', 1);
67+
const ONE_MINUTE = 1;
6868

6969
/**
7070
* One hour is 60 minutes.
7171
*/
72-
define(__NAMESPACE__ . '\\HOUR_IN_MINUTES', 60);
72+
const HOUR_IN_MINUTES = 60;
7373

7474
/**
7575
* One day is 24 hours.
7676
*/
77-
define(__NAMESPACE__ . '\\DAY_IN_MINUTES', 1440);
77+
const DAY_IN_MINUTES = 1440;
7878

7979
/**
8080
* One week is 7 days.
8181
*/
82-
define(__NAMESPACE__ . '\\WEEK_IN_MINUTES', 10080);
82+
const WEEK_IN_MINUTES = 10080;
8383

8484
/**
8585
* For general purposes, assume that one month is 30 days.
8686
*/
87-
define(__NAMESPACE__ . '\\MONTH_IN_MINUTES', 43200);
87+
const MONTH_IN_MINUTES = 43200;
8888

8989
/**
9090
* For general purposes, assume that one year is 365 days.
9191
*/
92-
define(__NAMESPACE__ . '\\YEAR_IN_MINUTES', 525600);
92+
const YEAR_IN_MINUTES = 525600;
9393

9494
/**
9595
* Common multipliers.
@@ -100,19 +100,19 @@
100100
/**
101101
* A millisecond is 1/1000 of a second.
102102
*/
103-
define(__NAMESPACE__ . '\\MILLISECONDS_PER_SECOND', 1000);
103+
const MILLISECONDS_PER_SECOND = 1000;
104104

105105
/**
106106
* A microsecond is one millionth of a second.
107107
*/
108-
define(__NAMESPACE__ . '\\MICROSECONDS_PER_SECOND', 1000000);
108+
const MICROSECONDS_PER_SECOND = 1000000;
109109

110110
/**
111111
* A nanosecond is one billionth of a second.
112112
*/
113-
define(__NAMESPACE__ . '\\NANOSECONDS_PER_SECOND', 1000000000);
113+
const NANOSECONDS_PER_SECOND = 1000000000;
114114

115115
/**
116116
* A picosecond is one trillionth of a second.
117117
*/
118-
define(__NAMESPACE__ . '\\PICOSECONDS_PER_SECOND', 1000000000000);
118+
const PICOSECONDS_PER_SECOND = 1000000000000;

src/GlobalAliases.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* either load this file via `autoload.files` in your `composer.json` file or by requiring the file
1010
* directly in your code.
1111
*
12-
* @package SteveGrunwell\TimeConstants
12+
* @package TimeConstants
1313
*/
1414

1515
declare(strict_types=1);

tests/ConstantsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Tests the definition of time constants.
1313
*
14-
* @package SteveGrunwell\TimeConstants
14+
* @package TimeConstants
1515
*/
1616
class ConstantsTest extends TestCase
1717
{

0 commit comments

Comments
 (0)