Skip to content

Commit 3fa619c

Browse files
amandiobmjamesmills
authored andcommitted
Accepting null as the first param of the convertToLocal method. (jamesmills#19)
* Accepting null * Docs
1 parent 1ae68f9 commit 3fa619c

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
],
1515
"require": {
16-
"php": ">=7",
16+
"php": ">=7.1",
1717
"laravel/framework": "5.6.* || 5.7.* || 5.8.* || ^6",
1818
"torann/geoip": "^1.0",
1919
"nesbot/carbon": "^1.0 || ^2.0"

src/Listeners/Auth/UpdateUsersTimezone.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ public function notify(\Torann\GeoIP\Location $geoip_info)
6969

7070
return;
7171
}
72+
}
7273

73-
/**
74-
* @return mixed
75-
*/
74+
/**
75+
* @return mixed
76+
*/
7677
public function getFromLookup()
7778
{
7879
$result = null;

src/Timezone.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77
class Timezone
88
{
9-
public function convertToLocal(Carbon $date, $format = null, $format_timezone = false)
9+
/**
10+
* @param Carbon|null $date
11+
* @param null $format
12+
* @param bool $format_timezone
13+
* @return string
14+
*/
15+
public function convertToLocal(?Carbon $date, $format = null, $format_timezone = false) : string
1016
{
1117
if (is_null($date)) {
1218
return 'Empty';
@@ -29,12 +35,20 @@ public function convertToLocal(Carbon $date, $format = null, $format_timezone =
2935
return $formatted_date_time;
3036
}
3137

38+
/**
39+
* @param $date
40+
* @return Carbon
41+
*/
3242
public function convertFromLocal($date) : Carbon
3343
{
3444
return Carbon::parse($date, auth()->user()->timezone)->setTimezone('UTC');
3545
}
3646

37-
public function formatTimezone(Carbon $date)
47+
/**
48+
* @param Carbon $date
49+
* @return string
50+
*/
51+
public function formatTimezone(Carbon $date) : string
3852
{
3953
$timezone = $date->format('e');
4054
$parts = explode('/', $timezone);

0 commit comments

Comments
 (0)