Skip to content

Commit

Permalink
Updates to Clock Component (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes authored Oct 23, 2023
1 parent 504e78a commit a9d42cf
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 26 deletions.
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"
}
]
}
}

0 comments on commit a9d42cf

Please sign in to comment.