PHP Class CommerceGuys\Addressing\Subdivision\SubdivisionRepository

Inheritance: implements CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface
Show file Open project: commerceguys/addressing

Protected Properties

Property Type Description
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepository The address format repository.
$definitionPath string The path where subdivision definitions are stored.
$definitions array Subdivision definitions.
$parents array Used as a cache to speed up instantiating subdivisions with the same parent. Contains only parents instead of all instantiated subdivisions to minimize duplicating the data in $this->definitions, thus reducing memory usage.

Public Methods

Method Description
__construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository = null, string $definitionPath = null ) Creates a SubdivisionRepository instance.
get ( $code, array $parents )
getAll ( array $parents )
getList ( array $parents, $locale = null )

Protected Methods

Method Description
buildGroup ( array $parents ) : string Builds a group from the provided parents.
createSubdivisionFromDefinitions ( integer $code, array $definitions ) : Subdivision Creates a subdivision object from the provided definitions.
hasData ( array $parents ) : boolean Checks whether predefined subdivisions exist for the provided parents.
loadDefinitions ( array $parents ) : array Loads the subdivision definitions for the provided parents.
processDefinitions ( array $definitions ) : array Processes the loaded definitions.

Method Details

__construct() public method

Creates a SubdivisionRepository instance.
public __construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository = null, string $definitionPath = null )
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface The address format repository.
$definitionPath string Path to the subdivision definitions.

buildGroup() protected method

Used for storing a country's subdivisions of a specific level.
protected buildGroup ( array $parents ) : string
$parents array The parents (country code, subdivision codes).
return string The group.

createSubdivisionFromDefinitions() protected method

Creates a subdivision object from the provided definitions.
protected createSubdivisionFromDefinitions ( integer $code, array $definitions ) : Subdivision
$code integer The subdivision code.
$definitions array The subdivision definitions.
return Subdivision

get() public method

public get ( $code, array $parents )
$parents array

getAll() public method

public getAll ( array $parents )
$parents array

getList() public method

public getList ( array $parents, $locale = null )
$parents array

hasData() protected method

Checks whether predefined subdivisions exist for the provided parents.
protected hasData ( array $parents ) : boolean
$parents array The parents (country code, subdivision codes).
return boolean TRUE if predefined subdivisions exist for the provided parents, FALSE otherwise.

loadDefinitions() protected method

Loads the subdivision definitions for the provided parents.
protected loadDefinitions ( array $parents ) : array
$parents array The parents (country code, subdivision codes).
return array The subdivision definitions.

processDefinitions() protected method

Adds keys and values that were removed from the JSON files for brevity.
protected processDefinitions ( array $definitions ) : array
$definitions array The definitions.
return array The processed definitions.

Property Details

$addressFormatRepository protected property

The address format repository.
protected AddressFormatRepository,CommerceGuys\Addressing\AddressFormat $addressFormatRepository
return CommerceGuys\Addressing\AddressFormat\AddressFormatRepository

$definitionPath protected property

The path where subdivision definitions are stored.
protected string $definitionPath
return string

$definitions protected property

Subdivision definitions.
protected array $definitions
return array

$parents protected property

Used as a cache to speed up instantiating subdivisions with the same parent. Contains only parents instead of all instantiated subdivisions to minimize duplicating the data in $this->definitions, thus reducing memory usage.
protected array $parents
return array