diff --git a/src/Field/SecondOfDay.php b/src/Field/SecondOfDay.php index 40b3a3f..55d10ac 100644 --- a/src/Field/SecondOfDay.php +++ b/src/Field/SecondOfDay.php @@ -22,6 +22,8 @@ final class SecondOfDay * @return void * * @throws DateTimeException If the second-of-day is not valid. + * + * @psalm-pure */ public static function check(int $secondOfDay) : void { diff --git a/src/LocalTime.php b/src/LocalTime.php index 94ad4b7..29c2b68 100644 --- a/src/LocalTime.php +++ b/src/LocalTime.php @@ -109,6 +109,8 @@ public static function of(int $hour, int $minute, int $second = 0, int $nano = 0 * @return LocalTime * * @throws DateTimeException + * + * @psalm-pure */ public static function ofSecondOfDay(int $secondOfDay, int $nanoOfSecond = 0) : LocalTime { diff --git a/src/TimeZoneOffset.php b/src/TimeZoneOffset.php index 335a5b1..11621fb 100644 --- a/src/TimeZoneOffset.php +++ b/src/TimeZoneOffset.php @@ -24,9 +24,7 @@ final class TimeZoneOffset extends TimeZone /** * The string representation of this time-zone offset. * - * This is generated on-the-fly, and will be null before the first call to getId(). - * - * @var string|null + * @var string */ private $id; @@ -38,6 +36,14 @@ final class TimeZoneOffset extends TimeZone private function __construct(int $totalSeconds) { $this->totalSeconds = $totalSeconds; + + if ($this->totalSeconds < 0) { + $this->id = '-' . LocalTime::ofSecondOfDay(- $this->totalSeconds); + } elseif ($this->totalSeconds > 0) { + $this->id = '+' . LocalTime::ofSecondOfDay($this->totalSeconds); + } else { + $this->id = 'Z'; + } } /** @@ -186,16 +192,6 @@ public function getTotalSeconds() : int */ public function getId() : string { - if ($this->id === null) { - if ($this->totalSeconds < 0) { - $this->id = '-' . LocalTime::ofSecondOfDay(- $this->totalSeconds); - } elseif ($this->totalSeconds > 0) { - $this->id = '+' . LocalTime::ofSecondOfDay($this->totalSeconds); - } else { - $this->id = 'Z'; - } - } - return $this->id; }