Skip to content

Commit 326f9e0

Browse files
apply code suggestions
Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
1 parent a37bbd6 commit 326f9e0

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

system/I18n/TimeTrait.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,13 +1021,11 @@ public function isAfter($testTime, ?string $timezone = null): bool
10211021
*
10221022
* If $start is after $end, the arguments are swapped.
10231023
*
1024-
* @param DateTimeInterface|self|string $start
1025-
* @param DateTimeInterface|self|string $end
1026-
* @param string|null $timezone Used only when $start or $end is a string.
1024+
* @param string|null $timezone Used only when $start or $end is a string.
10271025
*
10281026
* @throws Exception
10291027
*/
1030-
public function between($start, $end, bool $equals = true, ?string $timezone = null): bool
1028+
public function between(DateTimeInterface|string $start, DateTimeInterface|string $end, bool $inclusive = true, ?string $timezone = null): bool
10311029
{
10321030
$start = $this->normalizeTime($start, $timezone);
10331031
$end = $this->normalizeTime($end, $timezone);
@@ -1036,7 +1034,7 @@ public function between($start, $end, bool $equals = true, ?string $timezone = n
10361034
[$start, $end] = [$end, $start];
10371035
}
10381036

1039-
if ($equals) {
1037+
if ($inclusive) {
10401038
return ! $this->isBefore($start) && ! $this->isAfter($end);
10411039
}
10421040

@@ -1048,12 +1046,11 @@ public function between($start, $end, bool $equals = true, ?string $timezone = n
10481046
*
10491047
* If null is provided, compares against now in the current timezone.
10501048
*
1051-
* @param DateTimeInterface|self|string|null $time
1052-
* @param string|null $timezone Used only when $time is a string or null.
1049+
* @param string|null $timezone Used only when $time is a string or null.
10531050
*
10541051
* @throws Exception
10551052
*/
1056-
public function min($time = null, ?string $timezone = null): static
1053+
public function min(DateTimeInterface|string|null $time = null, ?string $timezone = null): static
10571054
{
10581055
$time = $this->normalizeTime($time, $timezone);
10591056

@@ -1065,12 +1062,11 @@ public function min($time = null, ?string $timezone = null): static
10651062
*
10661063
* If null is provided, compares against now in the current timezone.
10671064
*
1068-
* @param DateTimeInterface|self|string|null $time
1069-
* @param string|null $timezone Used only when $time is a string or null.
1065+
* @param string|null $timezone Used only when $time is a string or null.
10701066
*
10711067
* @throws Exception
10721068
*/
1073-
public function max($time = null, ?string $timezone = null): static
1069+
public function max(DateTimeInterface|string|null $time = null, ?string $timezone = null): static
10741070
{
10751071
$time = $this->normalizeTime($time, $timezone);
10761072

@@ -1206,11 +1202,9 @@ public function getUTCObject($time, ?string $timezone = null)
12061202
* or the current instance's timezone when omitted. If null is provided,
12071203
* the current time is used in the same timezone.
12081204
*
1209-
* @param DateTimeInterface|self|string|null $time
1210-
*
12111205
* @throws Exception
12121206
*/
1213-
private function normalizeTime($time, ?string $timezone = null): static
1207+
private function normalizeTime(DateTimeInterface|string|null $time, ?string $timezone = null): static
12141208
{
12151209
if ($time instanceof DateTimeInterface) {
12161210
return static::createFromInstance($time, $this->locale);

user_guide_src/source/libraries/time.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ between()
401401
.. versionadded:: 4.8.0
402402

403403
Determines if the current instance is between two other times. By default, the start and end bounds are included.
404-
Pass ``false`` as the third argument to exclude both bounds:
404+
Pass ``false`` as the third ``$inclusive`` argument to exclude both bounds:
405405

406406
.. literalinclude:: time/045.php
407407

0 commit comments

Comments
 (0)