CommerceGuys\Addressing\Formatter\PostalLabelFormatter::format PHP Метод

format() публичный Метод

public format ( CommerceGuys\Addressing\AddressInterface $address )
$address CommerceGuys\Addressing\AddressInterface
    public function format(AddressInterface $address)
    {
        if (empty($this->originCountryCode)) {
            throw new \RuntimeException("The originCountryCode can't be null.");
        }
        return parent::format($address);
    }

Usage Example

 /**
  * @covers \CommerceGuys\Addressing\Formatter\PostalLabelFormatter
  */
 public function testAddressLeadingPostPrefix()
 {
     $address = new Address();
     $address = $address->withCountryCode('CH')->withLocality('Herrliberg')->withPostalCode('8047');
     // Domestic mail shouldn't have the postal code prefix added.
     $expectedLines = ['8047 Herrliberg'];
     $this->formatter->setOriginCountryCode('CH');
     $formattedAddress = $this->formatter->format($address);
     $this->assertFormattedAddress($expectedLines, $formattedAddress);
     // International mail should have the postal code prefix added.
     $expectedLines = ['CH-8047 Herrliberg', 'SWITZERLAND'];
     $this->formatter->setOriginCountryCode('FR');
     $formattedAddress = $this->formatter->format($address);
     $this->assertFormattedAddress($expectedLines, $formattedAddress);
 }
All Usage Examples Of CommerceGuys\Addressing\Formatter\PostalLabelFormatter::format