8000 Added docblocks · laravel-shift/laravel-timezones@f5ada1e · GitHub
[go: up one dir, main page]

Skip to content

Commit f5ada1e

Browse files
committed
Added docblocks
1 parent 0d6cb1e commit f5ada1e

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/Casts/TimezonedDatetime.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Whitecube\LaravelTimezones\Facades\Timezone;
66
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
77
use Carbon\Carbon;
8-
use Carbon\CarbonInterface;
98
use DateTime;
109
use Illuminate\Support\Facades\Config;
1110
use Illuminate\Database\Eloquent\Model;
@@ -81,6 +80,7 @@ public function set($model, $key, $value, $attributes)
8180

8281
/**
8382
* Check if the given key is part of the model's known timestamps
83+
*
8484
* @param Model $model
8585
* @param string $key
8686
* @return bool
@@ -109,7 +109,13 @@ public function asDateTime($value, $timezone, $model)
109109
return $date->shiftTimezone($timezone);
110110
}
111111

112-
protected function hasTimezone($value): bool
112+
/**
113+
* Check if the provided value contains timezone information
114+
*
115+
* @param mixed $value
116+
* @return bool
117+
*/
118+
protected function hasTimezone(mixed $value): bool
113119
{
114120
return (is_string($value) && array_key_exists('zone', date_parse($value)))
115121
|| (is_a($value, DateTime::class) && $value->getTimezone());

src/Concerns/HasTimezonedTimestamps.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ protected function isDateAttribute($key)
2121

2222
/**
2323
* Check if key is a timezoned datetime cast
24+
*
25+
* @param string $key
26+
* @return bool
2427
*/
25-
protected function hasTimezonedDatetimeCast($key)
28+
protected function hasTimezonedDatetimeCast(string $key): bool
2629
{
2730
$casts = $this->getCasts();
2831

src/DatetimeParser.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@ class DatetimeParser
99
{
1010
use HasAttributes;
1111

12+
/**
13+
* The model's date storage format
14+
*/
1215
protected ?string $format;
1316

17+
/**
18+
* Parse the value into a carbon instance
19+
*
20+
* @param mixed $value
21+
* @param null|string $format
22+
* @return Carbon
23+
*/
1424
public function parse(mixed $value, ?string $format): Carbon
1525
{
1626
$this->format = $format;

0 commit comments

Comments
 (0)
0