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

Updates to Clock Component #32

Merged
merged 3 commits into from
Oct 23, 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
20 changes: 0 additions & 20 deletions src/SonsOfPHP/Component/Clock/ClockInterface.php

This file was deleted.

3 changes: 2 additions & 1 deletion src/SonsOfPHP/Component/Clock/FixedClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SonsOfPHP\Component\Clock;

use SonsOfPHP\Component\Clock\Exception\ClockException;
use Psr\Clock\ClockInterface;

/**
* Fixed Clock.
Expand All @@ -30,7 +31,7 @@ public function __toString(): string
return 'FixedClock[' . $this->zone->getName() . ']';
}

public function now(): \DateTimeInterface
public function now(): \DateTimeImmutable
{
return $this->time;
}
Expand Down
4 changes: 3 additions & 1 deletion src/SonsOfPHP/Component/Clock/SystemClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace SonsOfPHP\Component\Clock;

use Psr\Clock\ClockInterface;

/**
* System Clock.
*
Expand All @@ -23,7 +25,7 @@ public function __toString(): string
return 'SystemClock[' . $this->zone->getName() . ']';
}

public function now(): \DateTimeInterface
public function now(): \DateTimeImmutable
{
return new \DateTimeImmutable('now', $this->zone);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SonsOfPHP/Component/Clock/Tests/FixedClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace SonsOfPHP\Component\Clock\Tests;

use PHPUnit\Framework\TestCase;
use SonsOfPHP\Component\Clock\ClockInterface;
use Psr\Clock\ClockInterface;
use SonsOfPHP\Component\Clock\Exception\ClockException;
use SonsOfPHP\Component\Clock\FixedClock;

Expand Down
2 changes: 1 addition & 1 deletion src/SonsOfPHP/Component/Clock/Tests/SystemClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace SonsOfPHP\Component\Clock\Tests;

use PHPUnit\Framework\TestCase;
use SonsOfPHP\Component\Clock\ClockInterface;
use Psr\Clock\ClockInterface;
use SonsOfPHP\Component\Clock\SystemClock;

/**
Expand Down
5 changes: 3 additions & 2 deletions src/SonsOfPHP/Component/Clock/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1"
"php": ">=8.1",
"psr/clock": "^1.0"
},
"extra": {
"sort-packages": true,
Expand All @@ -59,4 +60,4 @@
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
]
}
}