Skip to content

Commit

Permalink
handle nullability
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-rubel committed Aug 30, 2022
1 parent 96cd34d commit ee8e2cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/Collection/DateFormatter.php
Expand Up @@ -20,13 +20,12 @@ public function __construct(
public string|null $timezone = null,
public string|null $date_format = 'Y-m-d',
) {
if (! $this->timezone) {
$this->timezone = config('app.timezone', 'UTC');
}

if (! $this->date instanceof CarbonInterface) {
$this->date = app(Carbon::class)->parse($this->date);
}

$this->timezone = $this->timezone ?? config('app.timezone', 'UTC');
$this->date_format = $this->date_format ?? 'Y-m-d';
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Collection/DateTimeFormatter.php
Expand Up @@ -20,13 +20,12 @@ public function __construct(
public string|null $timezone = null,
public string|null $datetime_format = 'Y-m-d H:i',
) {
if (! $this->timezone) {
$this->timezone = config('app.timezone', 'UTC');
}

if (! $this->datetime instanceof CarbonInterface) {
$this->datetime = app(Carbon::class)->parse($this->datetime);
}

$this->timezone = $this->timezone ?? config('app.timezone', 'UTC');
$this->datetime_format = $this->datetime_format ?? 'Y-m-d H:i';
}

/**
Expand Down

0 comments on commit ee8e2cb

Please sign in to comment.