Skip to content

Commit f3bd302

Browse files
committed
Consistent docblocks
1 parent 8a74054 commit f3bd302

File tree

5 files changed

+52
-49
lines changed

5 files changed

+52
-49
lines changed

src/Casts/TimezonedDatetime.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class TimezonedDatetime implements CastsAttributes
1414
{
1515
/**
16-
* A developer-specific format to use for string parsing
16+
* A developer-specific format to use for string parsing.
1717
*
1818
* @var null|string
1919
*/
@@ -22,7 +22,7 @@ class TimezonedDatetime implements CastsAttributes
2222
/**
2323
* Create a new casting instance.
2424
*
25-
* @param null|string $format
25+
* @param null|string $format
2626
* @return void
2727
*/
2828
public function __construct(?string $format = null)
@@ -48,12 +48,12 @@ public function get($model, $key, $value, $attributes)
4848
if ($this->isTimestamp($model, $key)) {
4949
$value = Carbon::parse($value)->format($this->format ?? $model->getDateFormat());
5050
}
51-
51+
5252
$original = Timezone::store($value, fn($raw, $tz) => $this->asDateTime($raw, $tz, $model));
5353

5454
return Timezone::date($original);
5555
}
56-
56+
5757
/**
5858
* Prepare the given value for storage.
5959
*
@@ -79,22 +79,22 @@ public function set($model, $key, $value, $attributes)
7979
}
8080

8181
/**
82-
* Check if the given key is part of the model's known timestamps
83-
*
84-
* @param Model $model
85-
* @param string $key
86-
* @return bool
82+
* Check if the given key is part of the model's known timestamps.
83+
*
84+
* @param Model $model
85+
* @param string $key
86+
* @return bool
8787
*/
8888
protected function isTimestamp(Model $model, string $key): bool
8989
{
9090
return $model->usesTimestamps() && in_array($key, $model->getDates());
9191
}
92-
92+
9393
/**
94-
* Create a new date value from raw material
94+
* Create a new date value from raw material.
9595
*
9696
* @param mixed $value
97-
* @param Carbon\CarbonTimeZone $timezone
97+
* @param \Carbon\CarbonTimeZone $timezone
9898
* @param \Illuminate\Database\Eloquent\Model $model
9999
* @return \Carbon\CarbonInterface
100100
*/
@@ -110,15 +110,14 @@ public function asDateTime($value, $timezone, $model)
110110
}
111111

112112
/**
113-
* Check if the provided value contains timezone information
114-
*
115-
* @param mixed $value
116-
* @return bool
113+
* Check if the provided value contains timezone information.
114+
*
115+
* @param mixed $value
116+
* @return bool
117117
*/
118118
protected function hasTimezone(mixed $value): bool
119119
{
120120
return (is_string($value) && array_key_exists('zone', date_parse($value)))
121121
|| (is_a($value, DateTime::class) && $value->getTimezone());
122122
}
123-
124123
}

src/Concerns/HasTimezonedTimestamps.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ protected function isDateAttribute($key)
2121
}
2222

2323
/**
24-
* Check if key is a timezoned datetime cast
25-
*
26-
* @param string $key
27-
* @return bool
24+
* Check if key is a timezoned datetime cast.
25+
*
26+
* @param string $key
27+
* @return bool
2828
*/
2929
protected function hasTimezonedDatetimeCast(string $key): bool
3030
{
@@ -37,8 +37,8 @@ protected function hasTimezonedDatetimeCast(string $key): bool
3737
$castClassName = explode(':', $cast)[0];
3838

3939
return in_array(
40-
$castClassName,
40+
$castClassName,
4141
[TimezonedDatetime::class, ImmutableTimezonedDatetime::class]
4242
);
4343
}
44-
}
44+
}

src/DatetimeParser.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class DatetimeParser
1010
use HasAttributes;
1111

1212
/**
13-
* The model's date storage format
13+
* The model's date storage format.
1414
*/
1515
protected ?string $format;
1616

1717
/**
18-
* Parse the value into a carbon instance
19-
*
20-
* @param mixed $value
21-
* @param null|string $format
18+
* Parse the value into a carbon instance.
19+
*
20+
* @param mixed $value
21+
* @param null|string $format
2222
* @return CarbonInterface
2323
*/
2424
public function parse(mixed $value, ?string $format): CarbonInterface
@@ -28,7 +28,6 @@ public function parse(mixed $value, ?string $format): CarbonInterface
2828
return $this->asDateTime($value);
2929
}
3030

31-
3231
/**
3332
* Get the format for database stored dates.
3433
*

src/Facades/Timezone.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class Timezone extends Facade
88
{
9+
/**
10+
* Get the registered name of the component.
11+
*
12+
* @return string
13+
*/
914
public static function getFacadeAccessor()
1015
{
1116
return \Whitecube\LaravelTimezones\Timezone::class;

src/Timezone.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ class Timezone
1212
use Macroable;
1313

1414
/**
15-
* The app's current display & manipulation timezone
15+
* The app's current display & manipulation timezone.
1616
*
1717
* @var \Carbon\CarbonTimeZone
1818
*/
1919
protected CarbonTimeZone $current;
2020
/**
21-
* The app's current storage timezone
21+
* The app's current storage timezone.
2222
*
2323
* @var \Carbon\CarbonTimeZone
2424
*/
@@ -27,7 +27,7 @@ class Timezone
2727
/**
2828
* Create a new singleton instance.
2929
*
30-
* @param string $default
30+
* @param string $default
3131
* @return void
3232
*/
3333
public function __construct(string $default)
@@ -41,7 +41,7 @@ public function __construct(string $default)
4141
*
4242
* Set the current application timezone.
4343
*
44-
* @param mixed $timezone
44+
* @param mixed $timezone
4545
* @return void
4646
*/
4747
public function set($timezone = null)
@@ -52,7 +52,7 @@ public function set($timezone = null)
5252
/**
5353
* Set the current application timezone.
5454
*
55-
* @param mixed $timezone
55+
* @param mixed $timezone
5656
* @return void
5757
*/
5858
public function setCurrent($timezone)
@@ -73,7 +73,7 @@ public function current(): CarbonTimeZone
7373
/**
7474
* Set the current database timezone.
7575
*
76-
* @param mixed $timezone
76+
* @param mixed $timezone
7777
* @return void
7878
*/
7979
public function setStorage($timezone)
@@ -104,8 +104,8 @@ public function now(): CarbonInterface
104104
/**
105105
* Configure given date for the application's current timezone.
106106
*
107-
* @param mixed $value
108-
* @param null|callable $maker
107+
* @param mixed $value
108+
* @param null|callable $maker
109109
* @return \Carbon\CarbonInterface
110110
*/
111111
public function date($value, callable $maker = null): CarbonInterface
@@ -116,8 +116,8 @@ public function date($value, callable $maker = null): CarbonInterface
116116
/**
117117
* Configure given date for the database storage timezone.
118118
*
119-
* @param mixed $value
120-
* @param null|callable $maker
119+
* @param mixed $value
120+
* @param null|callable $maker
121121
* @return \Carbon\CarbonInterface
122122
*/
123123
public function store($value, callable $maker = null): CarbonInterface
@@ -128,7 +128,7 @@ public function store($value, callable $maker = null): CarbonInterface
128128
/**
129129
* Duplicate the given date and shift its timezone to the application's current timezone.
130130
*
131-
* @param \Carbon\CarbonInterface
131+
* @param \Carbon\CarbonInterface $date
132132
* @return \Carbon\CarbonInterface
133133
*/
134134
protected function convertToCurrent(CarbonInterface $date): CarbonInterface
@@ -139,7 +139,7 @@ protected function convertToCurrent(CarbonInterface $date): CarbonInterface
139139
/**
140140
* Duplicate the given date and shift its timezone to the database's storage timezone.
141141
*
142-
* @param \Carbon\CarbonInterface
142+
* @param \Carbon\CarbonInterface $date
143143
* @return \Carbon\CarbonInterface
144144
*/
145145
protected function convertToStorage(CarbonInterface $date): CarbonInterface
@@ -150,8 +150,8 @@ protected function convertToStorage(CarbonInterface $date): CarbonInterface
150150
/**
151151
* Create or configure date using the application's current timezone.
152152
*
153-
* @param mixed $value
154-
* @param null|callable $maker
153+
* @param mixed $value
154+
* @param null|callable $maker
155155
* @return \Carbon\CarbonInterface
156156
*/
157157
protected function makeDateWithCurrent($value, callable $maker = null): CarbonInterface
@@ -164,8 +164,8 @@ protected function makeDateWithCurrent($value, callable $maker = null): CarbonIn
164164
/**
165165
* Create or configure date using the database's storage timezone.
166166
*
167-
* @param mixed $value
168-
* @param null|callable $maker
167+
* @param mixed $value
168+
* @param null|callable $maker
169169
* @return \Carbon\CarbonInterface
170170
*/
171171
protected function makeDateWithStorage($value, callable $maker = null): CarbonInterface
@@ -178,9 +178,9 @@ protected function makeDateWithStorage($value, callable $maker = null): CarbonIn
178178
/**
179179
* Create a date using the provided timezone.
180180
*
181-
* @param mixed $value
182-
* @param \Carbon\CarbonTimeZone $timezone
183-
* @param null|callable $maker
181+
* @param mixed $value
182+
* @param \Carbon\CarbonTimeZone $timezone
183+
* @param null|callable $maker
184184
* @return \Carbon\CarbonInterface
185185
*/
186186
protected function makeDate($value, CarbonTimeZone $timezone, callable $maker = null): CarbonInterface
@@ -193,7 +193,7 @@ protected function makeDate($value, CarbonTimeZone $timezone, callable $maker =
193193
/**
194194
* Create a Carbon timezone from given value.
195195
*
196-
* @param mixed $value
196+
* @param mixed $value
197197
* @return \Carbon\CarbonTimeZone
198198
*/
199199
protected function makeTimezone($value): CarbonTimeZone

0 commit comments

Comments
 (0)