PHP Класс CommerceGuys\Addressing\Formatter\DefaultFormatter

The address is formatted according to the destination country format. The localized country name is added to the formatted address.
Наследование: implements CommerceGuys\Addressing\Formatter\FormatterInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface The address format repository.
$countryRepository CommerceGuys\Addressing\Country\CountryRepositoryInterface The country repository.
$locale string The locale.
$options array The options.
$subdivisionRepository CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface The subdivision repository.

Открытые методы

Метод Описание
__construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository, CommerceGuys\Addressing\Country\CountryRepositoryInterface $countryRepository, CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface $subdivisionRepository, string $locale = null, array $options = [] ) Creates a DefaultFormatter instance.
format ( CommerceGuys\Addressing\AddressInterface $address )
getLocale ( )
getOption ( $key )
getOptions ( )
setLocale ( $locale )
setOption ( $key, $value )
setOptions ( array $options )

Защищенные методы

Метод Описание
buildView ( CommerceGuys\Addressing\AddressInterface $address, AddressFormat $addressFormat ) : array Builds the view for the given address.
cleanupOutput ( string $output ) : string Removes empty lines, leading punctuation, excess whitespace.
getDefaultOptions ( ) : array Gets the default options.
getValues ( CommerceGuys\Addressing\AddressInterface $address, AddressFormat $addressFormat ) : array Gets the address values used to build the view.
renderAttributes ( array $attributes ) : string Renders the given attributes.
renderView ( array $view ) : array Renders the given view.

Описание методов

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

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

buildView() защищенный Метод

Builds the view for the given address.
protected buildView ( CommerceGuys\Addressing\AddressInterface $address, AddressFormat $addressFormat ) : array
$address CommerceGuys\Addressing\AddressInterface The address.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
Результат array The view.

cleanupOutput() защищенный Метод

Removes empty lines, leading punctuation, excess whitespace.
protected cleanupOutput ( string $output ) : string
$output string The output that needs cleanup.
Результат string The cleaned up output.

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

public format ( CommerceGuys\Addressing\AddressInterface $address )
$address CommerceGuys\Addressing\AddressInterface

getDefaultOptions() защищенный Метод

Gets the default options.
protected getDefaultOptions ( ) : array
Результат array The default options.

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

public getLocale ( )

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

public getOption ( $key )

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

public getOptions ( )

getValues() защищенный Метод

Gets the address values used to build the view.
protected getValues ( CommerceGuys\Addressing\AddressInterface $address, AddressFormat $addressFormat ) : array
$address CommerceGuys\Addressing\AddressInterface The address.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
Результат array The values, keyed by address field.

renderAttributes() защищенный Метод

Renders the given attributes.
protected renderAttributes ( array $attributes ) : string
$attributes array The attributes.
Результат string The rendered attributes.

renderView() защищенный Метод

Renders the given view.
protected renderView ( array $view ) : array
$view array The view.
Результат array An array of rendered values with the original keys preserved.

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

public setLocale ( $locale )

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

public setOption ( $key, $value )

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

public setOptions ( array $options )
$options array

Описание свойств

$addressFormatRepository защищенное свойство

The address format repository.
protected AddressFormatRepositoryInterface,CommerceGuys\Addressing\AddressFormat $addressFormatRepository
Результат CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface

$countryRepository защищенное свойство

The country repository.
protected CountryRepositoryInterface,CommerceGuys\Addressing\Country $countryRepository
Результат CommerceGuys\Addressing\Country\CountryRepositoryInterface

$locale защищенное свойство

The locale.
protected string $locale
Результат string

$options защищенное свойство

The options.
protected array $options
Результат array

$subdivisionRepository защищенное свойство

The subdivision repository.
protected SubdivisionRepositoryInterface,CommerceGuys\Addressing\Subdivision $subdivisionRepository
Результат CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface