Skip to content

Commit 0aa0297

Browse files
author
Olivier Laviale
committed
Added the 'name' property.
1 parent bf1ba52 commit 0aa0297

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

lib/timezone.php

100644100755
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,34 @@ static public function from($source)
6969
return self::$cache[$source];
7070
}
7171

72+
/**
73+
* The name of the timezone.
74+
*
75+
* Note: This variable is only used to provide information during debugging.
76+
*
77+
* @var string
78+
*/
79+
private $name;
80+
7281
/**
7382
* Location of the timezone.
7483
*
7584
* @var TimeZoneLocation
7685
*/
7786
private $location;
7887

88+
/**
89+
* Initializes the {@link $name} property.
90+
*
91+
* @param string $timezone
92+
*/
93+
public function __construct($timezone)
94+
{
95+
parent::__construct($timezone);
96+
97+
$this->name = $this->getName();
98+
}
99+
79100
/**
80101
* Returns the {@link $location}, {@link $name} and {@link $offset} properties.
81102
*
@@ -96,7 +117,7 @@ public function __get($property)
96117

97118
case 'name':
98119

99-
return $this->getName();
120+
return $this->name;
100121

101122
case 'offset':
102123

@@ -127,6 +148,6 @@ public function __get($property)
127148
*/
128149
public function __toString()
129150
{
130-
return $this->getName();
151+
return $this->name;
131152
}
132153
}

0 commit comments

Comments
 (0)