| Conditions | 7 |
| Paths | 7 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 504 | public function get(string $host): string { |
|
| 29 | 504 | if (!isset($this->timeZones[$host])) { |
|
| 30 | 504 | $timeZone = null; |
|
| 31 | 504 | $net = $this->system->getNetPath(); |
|
| 32 | // for local domain names we can assume same timezone |
||
| 33 | 504 | if ($net && $host && strpos($host, '.') !== false) { |
|
|
|
|||
| 34 | 4 | $command = sprintf( |
|
| 35 | 4 | '%s time zone -S %s', |
|
| 36 | $net, |
||
| 37 | 4 | escapeshellarg($host) |
|
| 38 | ); |
||
| 39 | 4 | $timeZone = exec($command); |
|
| 40 | } |
||
| 41 | |||
| 42 | 504 | if (!$timeZone) { |
|
| 43 | 500 | $date = $this->system->getDatePath(); |
|
| 44 | 500 | if ($date) { |
|
| 45 | 496 | $timeZone = exec($date . " +%z"); |
|
| 46 | } else { |
||
| 47 | 4 | $timeZone = date_default_timezone_get(); |
|
| 48 | } |
||
| 49 | } |
||
| 50 | 504 | $this->timeZones[$host] = $timeZone; |
|
| 51 | } |
||
| 52 | 504 | return $this->timeZones[$host]; |
|
| 53 | } |
||
| 54 | } |
||
| 55 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: