CountryService

Implements \CountryServiceInterface

Class CountryService

This class is used for finding country data

category

System

package

Customer

subpackage

Country

implements

CountryServiceInterface

Methods

Constructor of the class CountryService

__construct(\CustomerCountryRepositoryInterface $customerCountryRepo, \CustomerCountryZoneRepositoryInterface $customerCountryZoneRepo) 

Arguments

$customerCountryZoneRepo

\CustomerCountryZoneRepositoryInterface

Checks if country has country zones

countryHasCountryZones(\CustomerCountryInterface $customerCountry) : boolean

Arguments

$customerCountry

\CustomerCountryInterface

Response

boolean

true|false if there are|are not country zones

Checks if there is a country zone in a country

countryZoneExistsInCountry(\CustomerCountryZoneInterface $customerCountryZone, \CustomerCountryInterface $customerCountry) : boolean

Arguments

$customerCountryZone

\CustomerCountryZoneInterface

$customerCountry

\CustomerCountryInterface

Response

boolean

true|false if country zone exists|not exists

Find country by iso2 code.

findCountryByIso2(string $p_countryIso2) : \CustomerCountryInterface|null

Arguments

$p_countryIso2

string

Response

\CustomerCountryInterface|null

Find country by name.

findCountryByName(string $p_countryName) : \CustomerCountryInterface

Arguments

$p_countryName

string

Response

\CustomerCountryInterface

This method returns a CustomerCountryZone object if found. Otherwise null will be returned.

findCountryZoneByNameAndCountry(\CustomerCountryZoneNameInterface|string $p_zoneName, \CustomerCountryInterface $customerCountry) : \CustomerCountryZoneInterface|null

Arguments

$customerCountry

\CustomerCountryInterface

Response

\CustomerCountryZoneInterface|null

Finds the country zone by the given zone code and country.

findCountryZoneByZoneCodeAndCountry(\CustomerCountryZoneIsoCode $zoneCode, \CustomerCountryInterface $country) : \CustomerCountryZoneInterface|null

Null will be returned if no results are found.

Arguments

$zoneCode

\CustomerCountryZoneIsoCode

Zone code of expected country zone.

$country

\CustomerCountryInterface

Country of zone.

Response

\CustomerCountryZoneInterface|null

Country zone model.

Returns the country zone by the given zone code and country id.

findCountryZoneByZoneCodeAndCountryId(\CustomerCountryZoneIsoCode $zoneCode, \IdType $countryId) : \CustomerCountryZoneInterface

Null will be returned if no results are found.

Arguments

$zoneCode

\CustomerCountryZoneIsoCode

Zone code of expected country zone.

$countryId

\IdType

Country id of zone.

Response

\CustomerCountryZoneInterface

Country zone model.

This method will return an array of CustomerCountryZone objects found by the country ID. If the country has no zones, an empty array will be returned

findCountryZonesByCountryId(\IdType $countryId) : array

Arguments

$countryId

\IdType

Response

array

of CustomerCountryZone objects

Getter method for the country ID

getCountryById(\IdType $id) : \CustomerCountryInterface

Arguments

$id

\IdType

Response

\CustomerCountryInterface

Get country by iso2 code.

getCountryByIso2(string $p_countryIso2) : \CustomerCountryInterface

Arguments

$p_countryIso2

string

Response

\CustomerCountryInterface

Get country by name.

getCountryByName(string $p_countryName) : \CustomerCountryInterface

Arguments

$p_countryName

string

Response

\CustomerCountryInterface

getCountryZoneById

getCountryZoneById(\IdType $id) : \CustomerCountryZoneInterface

Arguments

$id

\IdType

Response

\CustomerCountryZoneInterface

Getter method for the country zone

getCountryZoneByNameAndCountry(\CustomerCountryZoneNameInterface|string $p_zoneName, \CustomerCountryInterface $customerCountry) : \CustomerCountryZoneInterface

Arguments

$customerCountry

\CustomerCountryInterface

Response

\CustomerCountryZoneInterface

Returns the country zone by the given zone code and country.

getCountryZoneByZoneCodeAndCountry(\CustomerCountryZoneIsoCode $zoneCode, \CustomerCountryInterface $country) : \CustomerCountryZoneInterface

An error will be raised if no results are found.

Throws
\CountryZoneNotFoundException

If no results was found by provided arguments.

Arguments

$zoneCode

\CustomerCountryZoneIsoCode

Zone code of expected country zone.

$country

\CustomerCountryInterface

Country of zone.

Response

\CustomerCountryZoneInterface

Country zone model.

Returns the country zone by the given zone code and country id.

getCountryZoneByZoneCodeAndCountryId(\CustomerCountryZoneIsoCode $zoneCode, \IdType $countryId) : \CustomerCountryZoneInterface

An error will be raised if no results are found.

Throws
\CountryZoneNotFoundException

If no results was found by provided arguments.

Arguments

$zoneCode

\CustomerCountryZoneIsoCode

Zone code of expected country zone.

$countryId

\IdType

Country id of zone.

Response

\CustomerCountryZoneInterface

Country zone model.

This method will return a new CustomerCountryZone object representing an unknown country zone.

getUnknownCountryZoneByName(string $p_zoneName) : \CustomerCountryZone

Arguments

$p_zoneName

string

Response

\CustomerCountryZone

This method returns whether the specified country, necessary, needs a state.

isStateMandatory(\IdType $countryId) : boolean

Arguments

$countryId

\IdType

Response

boolean

Properties

customerCountryRepo

customerCountryRepo : \CustomerCountryRepositoryInterface

customerCountryZoneRepo

customerCountryZoneRepo : \CustomerCountryZoneRepositoryInterface