| Conditions | 6 |
| Paths | 3 |
| Total Lines | 13 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function Nice() { |
||
| 13 | if($timestamp = $this){ |
||
| 14 | //instantiate new DateTime object based off received timestamp in the default timezone |
||
| 15 | $timestamp = new DateTime($timestamp, new DateTimeZone(date_default_timezone_get())); |
||
| 16 | //if a user is logged in, has set a timezone that is in the allowed list and |
||
| 17 | //that timezone is NOT the default one then convert the timestamp to use the selected timezone |
||
| 18 | if(Member::currentUserID() && isset(Member::CurrentUser()->Timezone) && in_array(Member::CurrentUser()->Timezone, timezone_identifiers_list()) && Member::CurrentUser()->Timezone != date_default_timezone_get()){ |
||
| 19 | $timestamp->setTimezone(new DateTimeZone(Member::CurrentUser()->Timezone)); |
||
| 20 | } |
||
| 21 | } |
||
| 22 | //return timestamp in "Nice" format + the user's timezone |
||
| 23 | return $timestamp->Format('d/m/Y g:ia'); |
||
| 24 | } |
||
| 25 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.