| Total Complexity | 7 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | trait TimezoneTrait |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * The timezone |
||
| 27 | * @var string|NULL |
||
| 28 | */ |
||
| 29 | protected ?string $timezoneString = null; |
||
| 30 | private ?string $timezoneVariable = null; |
||
| 31 | |||
| 32 | protected function validateSyntax_check_timezone(): void |
||
| 33 | { |
||
| 34 | // first, check if we have an explicit timezone |
||
| 35 | $tokens = $this->requireParams() |
||
|
|
|||
| 36 | ->getInfo() |
||
| 37 | ->getStringLiterals(); |
||
| 38 | |||
| 39 | if (count($tokens) > 1) { |
||
| 40 | $this->timezoneString = $tokens[1]->getText(); |
||
| 41 | return; |
||
| 42 | } |
||
| 43 | |||
| 44 | // then, check if a variable is used for timezone |
||
| 45 | $variables = $this->requireParams() |
||
| 46 | ->getInfo() |
||
| 47 | ->getVariables(); |
||
| 48 | |||
| 49 | if (count($variables) > 1) { |
||
| 50 | $this->timezoneVariable = $variables[1]->getFullName(); |
||
| 51 | return; |
||
| 52 | } |
||
| 53 | |||
| 54 | // neither explicit timezone nor variable present, so use nothing |
||
| 55 | $this->timezoneString= null; |
||
| 56 | $this->timezoneVariable = null; |
||
| 57 | } |
||
| 58 | |||
| 59 | public function getTimezoneString(): ?string |
||
| 60 | { |
||
| 61 | return $this->timezoneString; |
||
| 62 | } |
||
| 63 | |||
| 64 | public function getTimezoneVariable() : ?string |
||
| 65 | { |
||
| 66 | return $this->timezoneVariable; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function hasTimezone() : bool |
||
| 72 | } |
||
| 73 | } |
||
| 74 |