| Total Complexity | 10 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Timezone |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param Carbon\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, $enableTranslation = null) : string |
||
| 16 | { |
||
| 17 | if (is_null($date)) { |
||
| 18 | return __('Empty'); |
||
| 19 | } |
||
| 20 | |||
| 21 | $timezone = (auth()->user()->timezone) ?? config('app.timezone'); |
||
| 22 | |||
| 23 | $enableTranslation = $enableTranslation !== null ? $enableTranslation : config('timezone.enableTranslation'); |
||
| 24 | |||
| 25 | $date->setTimezone($timezone); |
||
| 26 | |||
| 27 | if (is_null($format)) { |
||
| 28 | return $enableTranslation ? $date->translatedFormat(config('timezone.format')) : $date->format(config('timezone.format')); |
||
| 29 | } |
||
| 30 | |||
| 31 | $formatted_date_time = $enableTranslation ? $date->translatedFormat($format) : $date->format($format); |
||
| 32 | |||
| 33 | if ($format_timezone) { |
||
| 34 | return $formatted_date_time . ' ' . $this->formatTimezone($date); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $formatted_date_time; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param $date |
||
| 42 | * @return Carbon\Carbon |
||
| 43 | */ |
||
| 44 | public function convertFromLocal($date) : Carbon |
||
| 45 | { |
||
| 46 | return Carbon::parse($date, auth()->user()->timezone)->setTimezone('UTC'); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param Carbon\Carbon $date |
||
| 51 | * @return string |
||
| 52 | */ |
||
| 53 | private function formatTimezone(Carbon $date) : string |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths