File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,6 +235,13 @@ public function withFeatureComponentAnalysis() {
235235 return $ this ->withCustomCommaSeparatedQuery ("features " , "component-analysis " );
236236 }
237237
238+ /**
239+ * withFeatureIanaTimeZone turns on the IANA timezone feature for the request.
240+ */
241+ public function withFeatureIanaTimeZone () {
242+ return $ this ->withCustomCommaSeparatedQuery ("features " , "iana-timezone " );
243+ }
244+
238245 public function buildUSAutocompleteProApiClient () {
239246 $ this ->ensureURLPrefixNotNull (self ::US_AUTOCOMPLETE_PRO_API_URL );
240247 return new USAutoCompleteProApiClient ($ this ->buildSender (), $ this ->serializer );
Original file line number Diff line number Diff line change @@ -26,6 +26,9 @@ public function __construct($obj) {
2626 $ this ->timeZone = ArrayUtil::getField ($ obj , 'time_zone ' );
2727 $ this ->utcOffset = ArrayUtil::getField ($ obj , 'utc_offset ' );
2828 $ this ->obeysDst = ArrayUtil::getField ($ obj , 'dst ' );
29+ $ this ->ianaTimeZone = ArrayUtil::getField ($ obj , 'iana_time_zone ' );
30+ $ this ->ianaUtcOffset = ArrayUtil::getField ($ obj , 'iana_utc_offset ' );
31+ $ this ->ianaObeysDst = ArrayUtil::getField ($ obj , 'iana_dst ' );
2932 $ this ->isEwsMatch = ArrayUtil::getField ($ obj , 'ews_match ' );
3033 }
3134
@@ -45,6 +48,9 @@ public function __construct($obj) {
4548 $ timeZone ,
4649 $ utcOffset ,
4750 $ obeysDst ,
51+ $ ianaTimeZone ,
52+ $ ianaUtcOffset ,
53+ $ ianaObeysDst ,
4854 $ isEwsMatch ;
4955
5056 //region [ Getters ]
@@ -113,6 +119,18 @@ public function obeysDst() {
113119 return $ this ->obeysDst ;
114120 }
115121
122+ public function getIanaTimeZone () {
123+ return $ this ->ianaTimeZone ;
124+ }
125+
126+ public function getIanaUtcOffset () {
127+ return $ this ->ianaUtcOffset ;
128+ }
129+
130+ public function obeysIanaDst () {
131+ return $ this ->ianaObeysDst ;
132+ }
133+
116134 public function isEwsMatch () {
117135 return $ this ->isEwsMatch ;
118136 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace SmartyStreets \PhpSdk \Tests ;
4+
5+ require_once (dirname (dirname (__FILE__ )) . '/src/ClientBuilder.php ' );
6+
7+ use SmartyStreets \PhpSdk \ClientBuilder ;
8+ use PHPUnit \Framework \TestCase ;
9+
10+ class ClientBuilderTest extends TestCase {
11+
12+ public function testWithFeatureIANATimeZone () {
13+ $ builder = new ClientBuilder ();
14+ $ builder ->withFeatureIanaTimeZone ();
15+
16+ $ this ->assertEquals ('iana-timezone ' , $ this ->getCustomQuery ($ builder )['features ' ]);
17+ }
18+
19+ public function testWithFeatureIANATimeZoneAndComponentAnalysis_ShouldAppend () {
20+ $ builder = new ClientBuilder ();
21+ $ builder ->withFeatureComponentAnalysis ();
22+ $ builder ->withFeatureIanaTimeZone ();
23+
24+ $ this ->assertEquals ('component-analysis,iana-timezone ' , $ this ->getCustomQuery ($ builder )['features ' ]);
25+ }
26+
27+ private function getCustomQuery (ClientBuilder $ builder ) {
28+ $ reflection = new \ReflectionClass ($ builder );
29+ $ property = $ reflection ->getProperty ('customQuery ' );
30+ $ property ->setAccessible (true );
31+ return $ property ->getValue ($ builder );
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ public function setUp() : void {
5858 'time_zone ' => '39 ' ,
5959 'utc_offset ' => 40.0 ,
6060 'dst ' => true ,
61+ 'iana_time_zone ' => 'America/Denver ' ,
62+ 'iana_utc_offset ' => -7.0 ,
63+ 'iana_dst ' => true ,
6164 'ews_match ' => true
6265 ),
6366 'analysis ' => array (
@@ -144,6 +147,9 @@ public function testAllFieldsFilledCorrectly() {
144147 $ this ->assertEquals ('39 ' , $ metadata ->getTimeZone ());
145148 $ this ->assertEquals (40.0 , $ metadata ->getUtcOffset ());
146149 $ this ->assertEquals (true , $ metadata ->obeysDst ());
150+ $ this ->assertEquals ('America/Denver ' , $ metadata ->getIanaTimeZone ());
151+ $ this ->assertEquals (-7.0 , $ metadata ->getIanaUtcOffset ());
152+ $ this ->assertEquals (true , $ metadata ->obeysIanaDst ());
147153 $ this ->assertEquals (true , $ metadata ->isEwsMatch ());
148154
149155 $ analysis = $ candidate ->getAnalysis ();
You can’t perform that action at this time.
0 commit comments