コード例 #1
0
 public function testReverseFormat()
 {
     $this->formatter->setPostalCode('S4T 0H0');
     $this->assertEquals('S4T0H0', $this->formatter->reverseFormat());
     $this->formatter->setDisplayFormat(PostalCodeFormatter::FORMAT_USA);
     $this->formatter->setPostalCode('12345');
     $this->assertEquals('12345', $this->formatter->format());
 }
コード例 #2
0
 /**
  * Transforms an unformatted postal code (user-inputted) into one that conforms to better
  * database standards - 6 characters max, no special characters
  *
  * S4P   0 H 0 => 12324567890
  *
  * @param mixed $unformattedPostalCode
  *
  * @return mixed|void
  */
 public function reverseTransform($unformattedPostalCode)
 {
     $postalCode = new PostalCodeFormatter($unformattedPostalCode, $this->postalCodeFormat);
     return $postalCode->reverseFormat();
 }