CommerceGuys\Addressing\Formatter\DefaultFormatter::__construct PHP Method

__construct() public method

Creates a DefaultFormatter instance.
public __construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository, CommerceGuys\Addressing\Country\CountryRepositoryInterface $countryRepository, CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface $subdivisionRepository, string $locale = null, array $options = [] )
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface
$countryRepository CommerceGuys\Addressing\Country\CountryRepositoryInterface
$subdivisionRepository CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface
$locale string
$options array
    public function __construct(AddressFormatRepositoryInterface $addressFormatRepository, CountryRepositoryInterface $countryRepository, SubdivisionRepositoryInterface $subdivisionRepository, $locale = null, array $options = [])
    {
        $this->addressFormatRepository = $addressFormatRepository;
        $this->countryRepository = $countryRepository;
        $this->subdivisionRepository = $subdivisionRepository;
        $this->locale = $locale;
        $this->setOptions($options);
    }

Usage Example

 /**
  * Creates a PostalFormatter instance.
  *
  * @param AddressFormatRepositoryInterface $addressFormatRepository
  * @param CountryRepositoryInterface       $countryRepository
  * @param SubdivisionRepositoryInterface   $subdivisionRepository
  * @param string                           $originCountryCode
  * @param string                           $locale
  * @param array                            $options
  */
 public function __construct(AddressFormatRepositoryInterface $addressFormatRepository, CountryRepositoryInterface $countryRepository, SubdivisionRepositoryInterface $subdivisionRepository, $originCountryCode = null, $locale = null, array $options = [])
 {
     if (!function_exists('mb_strtoupper')) {
         throw new \RuntimeException('The "mbstring" extension is required by this class.');
     }
     $this->originCountryCode = $originCountryCode;
     parent::__construct($addressFormatRepository, $countryRepository, $subdivisionRepository, $locale, $options);
 }