Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename toNative() toDateTimeImmutable() #424

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ChronosDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1564,11 +1564,11 @@ public function diffForHumans(?ChronosDate $other = null, bool $absolute = false
}

/**
* Returns the date as a DateTimeImmutable instance.
* Returns the date as a `DateTimeImmutable` instance.
*
* @return \DateTimeImmutable
*/
public function toNative(): DateTimeImmutable
public function toDateTimeImmutable(): DateTimeImmutable
{
return $this->native;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ChronosTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected static function mod(int $a, int $b): int
*/
public function format(string $format): string
{
return $this->toNative()->format($format);
return $this->toDateTimeImmutable()->format($format);
}

/**
Expand Down Expand Up @@ -404,7 +404,7 @@ public function between(ChronosTime $start, ChronosTime $end, bool $equals = tru
*
* @return \DateTimeImmutable
*/
public function toNative(): DateTimeImmutable
public function toDateTimeImmutable(): DateTimeImmutable
{
return (new DateTimeImmutable())->setTime(
$this->getHours(),
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/ChronosTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public function testComparisons(): void
$this->assertFalse($t3->between($t1, $t2));
}

public function testToNative(): void
public function testToDateTimeImmutable(): void
{
$native = ChronosTime::parse('23:59:59.999999')->toNative();
$native = ChronosTime::parse('23:59:59.999999')->toDateTimeImmutable();
$this->assertSame('23:59:59.999999', $native->format('H:i:s.u'));
}
}
4 changes: 2 additions & 2 deletions tests/TestCase/Date/StringsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ public function testToW3cString()
$this->assertSame('1975-12-25T00:00:00+00:00', $d->toW3cString());
}

public function testToNative(): void
public function testToDateTimeImmutable(): void
{
$d = ChronosDate::now();
$this->assertSame($d->format('Y-m-d'), $d->toNative()->format('Y-m-d'));
$this->assertSame($d->format('Y-m-d'), $d->toDateTimeImmutable()->format('Y-m-d'));
}
}