Skip to content

Commit

Permalink
Fix psalm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Jan 8, 2021
1 parent 9ac39d1 commit ce4525d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/Timezones/TimezoneTransitionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,20 @@ public function getTransitions(): array
$this->end->getTimestamp(),
);

// for timezone '+00:00' DateTimeZone::getTransitions() returns boolean false,
// so check for that first and create the fake entry to make it work
if ($transitions === false) {
$transitions = [[
'isdst' => false,
'offset' => 0,
'ts' => $this->start->getTimestamp(),
'abbr' => 'UTC',
]];
} elseif (count($transitions) === 1) {
// for timezone '+00:00' DateTimeZone::getTransitions() returns boolean false,
// so check for that first and create the fake entry to make it work
$transitions = [
[
'isdst' => false,
'offset' => 0,
'ts' => $this->start->getTimestamp(),
'abbr' => 'UTC',
],
];
}

if (count($transitions) === 1) {
// Add a fake transition for UTC for example which does not have transitions
$transitions[] = [
'isdst' => $transitions[0]["isdst"],
Expand All @@ -68,8 +72,8 @@ public function getTransitions(): array
? TimezoneEntryType::daylight()
: TimezoneEntryType::standard();

$offsetFrom = $this->resolveOffset((int) $previousTransition['offset']);
$offsetTo = $this->resolveOffset((int) $transition['offset']);
$offsetFrom = $this->resolveOffset($previousTransition['offset']);
$offsetTo = $this->resolveOffset($transition['offset']);

$offsetDiff = $this->resolveOffsetDiff($offsetFrom, $offsetTo);

Expand Down

0 comments on commit ce4525d

Please sign in to comment.