diff --git a/src/Utils/Tokenizer.php b/src/Utils/Tokenizer.php index a2e18b2..d996725 100755 --- a/src/Utils/Tokenizer.php +++ b/src/Utils/Tokenizer.php @@ -10,18 +10,14 @@ public static function outward($postcode) { self::sanityCheck($postcode); - $postcodeStart = trim(substr($postcode, 0, -3)); - - return $postcodeStart; + return strtoupper(trim(substr($postcode, 0, -3))); } public static function inward($postcode) { self::sanityCheck($postcode); - $postcodeEnd = trim(substr($postcode, -3, 3)); - - return $postcodeEnd; + return strtoupper(trim(substr($postcode, -3, 3))); } private static function sanityCheck($postcode) diff --git a/tests/Unit/BasicUsageTest.php b/tests/Unit/BasicUsageTest.php index f114ff2..80f9e22 100644 --- a/tests/Unit/BasicUsageTest.php +++ b/tests/Unit/BasicUsageTest.php @@ -10,7 +10,7 @@ final class BasicUsageTest extends TestCase { public function testValidation() { - $postcodes = ['ST163DP', 'TN30YA', 'ST78PP', 'CM233WE', 'E16AW', 'E106QX', 'ST16 3DP']; + $postcodes = ['ST163DP', 'TN30YA', 'ST78PP', 'CM233WE', 'E16AW', 'E106QX', 'ST16 3DP', 'st16 3dp']; foreach ($postcodes as $postcode) { $this->assertTrue(Validator::validatePostcode($postcode)); @@ -82,6 +82,11 @@ public function testOutwardAndInwardCodes() 'outward' => 'E1', 'inward' => '6AW', ], + [ + 'postcode' => 'e1 6aw', + 'outward' => 'E1', + 'inward' => '6AW', + ], ]; foreach ($postcodeTestItems as $postcodeTestItem) {