From 0c124653526a5033952b1314470a5a8e47494355 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Thu, 10 Nov 2022 23:47:14 -0700 Subject: [PATCH] Fill out tracking location from a city lookup sometimes (just see comments) --- lib/Tracking_USPS.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Tracking_USPS.lib.php b/lib/Tracking_USPS.lib.php index 6405735..9d8344c 100644 --- a/lib/Tracking_USPS.lib.php +++ b/lib/Tracking_USPS.lib.php @@ -6,7 +6,7 @@ class Tracking_USPS { * Sometimes the API returns a city but no state or ZIP. This is a lookup table of city => state * so the API can return a more complete response. */ - public $STATELESS_CITIES = [ + public const STATELESS_CITIES = [ "LOS ANGELES" => "CA", "NEW YORK" => "NY" ]; @@ -81,8 +81,8 @@ class Tracking_USPS { * Fill in state from list above when it's missing from the API response */ if ($current_location->state == "" && $current_location->zip == "") { - if (in_array(strtoupper($current_location->city), $STATELESS_CITIES)) { - $current_location->state = $STATELESS_CITIES[$current_location->city]; + if (array_key_exists(strtoupper($current_location->city), self::STATELESS_CITIES)) { + $current_location->state = self::STATELESS_CITIES[$current_location->city]; } } @@ -119,8 +119,8 @@ class Tracking_USPS { * Fill in state from list above when it's missing from the API response */ if ($location->state == "" && $location->zip == "") { - if (in_array(strtoupper($location->city), $STATELESS_CITIES)) { - $location->state = $STATELESS_CITIES[$location->city]; + if (array_key_exists(strtoupper($location->city), self::STATELESS_CITIES)) { + $location->state = self::STATELESS_CITIES[$location->city]; } } if ((empty($history->EventDate) || empty($history->EventTime)) && $i < count($trackinfo->TrackDetail) - 1) {