CountryService
in package
implements
CountryServiceInterface
Class CountryService
This class is used for finding country data
Tags
Interfaces, Classes and Traits
- CountryServiceInterface
- Interface CountryServiceInterface
Table of Contents
- $customerCountryRepo : CustomerCountryRepositoryInterface
- $customerCountryZoneRepo : CustomerCountryZoneRepositoryInterface
- __construct() : mixed
- Constructor of the class CountryService
- countryHasCountryZones() : bool
- Checks if country has country zones
- countryZoneExistsInCountry() : bool
- Checks if there is a country zone in a country
- findCountryByIso2() : CustomerCountryInterface|null
- Find country by iso2 code.
- findCountryByName() : CustomerCountryInterface
- Find country by name.
- findCountryZoneByNameAndCountry() : CustomerCountryZoneInterface|null
- This method returns a CustomerCountryZone object if found. Otherwise null will be returned.
- findCountryZoneByZoneCodeAndCountry() : CustomerCountryZoneInterface|null
- Finds the country zone by the given zone code and country.
- findCountryZoneByZoneCodeAndCountryId() : CustomerCountryZoneInterface
- Returns the country zone by the given zone code and country id.
- findCountryZonesByCountryId() : array<string|int, mixed>
- 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
- getCountries() : CustomerCountryCollection
- Getter method for all countries
- getCountryById() : CustomerCountryInterface
- Getter method for the country ID
- getCountryByIso2() : CustomerCountryInterface
- Get country by iso2 code.
- getCountryByName() : CustomerCountryInterface
- Get country by name.
- getCountryZoneById() : CustomerCountryZoneInterface
- getCountryZoneByNameAndCountry() : CustomerCountryZoneInterface
- Getter method for the country zone
- getCountryZoneByZoneCodeAndCountry() : CustomerCountryZoneInterface
- Returns the country zone by the given zone code and country.
- getCountryZoneByZoneCodeAndCountryId() : CustomerCountryZoneInterface
- Returns the country zone by the given zone code and country id.
- getUnknownCountryZoneByName() : CustomerCountryZone
- This method will return a new CustomerCountryZone object representing an unknown country zone.
- isStateMandatory() : bool
- This method returns whether the specified country, necessary, needs a state.
Properties
$customerCountryRepo
protected
CustomerCountryRepositoryInterface
$customerCountryRepo
$customerCountryZoneRepo
protected
CustomerCountryZoneRepositoryInterface
$customerCountryZoneRepo
Methods
__construct()
Constructor of the class CountryService
public
__construct(CustomerCountryRepositoryInterface $customerCountryRepo, CustomerCountryZoneRepositoryInterface $customerCountryZoneRepo) : mixed
Parameters
- $customerCountryRepo : CustomerCountryRepositoryInterface
- $customerCountryZoneRepo : CustomerCountryZoneRepositoryInterface
Return values
mixed —countryHasCountryZones()
Checks if country has country zones
public
countryHasCountryZones(CustomerCountryInterface $customerCountry) : bool
Parameters
- $customerCountry : CustomerCountryInterface
Return values
bool —true|false if there are|are not country zones
countryZoneExistsInCountry()
Checks if there is a country zone in a country
public
countryZoneExistsInCountry(CustomerCountryZoneInterface $customerCountryZone, CustomerCountryInterface $customerCountry) : bool
Parameters
- $customerCountryZone : CustomerCountryZoneInterface
- $customerCountry : CustomerCountryInterface
Return values
bool —true|false if country zone exists|not exists
findCountryByIso2()
Find country by iso2 code.
public
findCountryByIso2(string $p_countryIso2) : CustomerCountryInterface|null
Parameters
- $p_countryIso2 : string
Return values
CustomerCountryInterface|null —findCountryByName()
Find country by name.
public
findCountryByName(string $p_countryName) : CustomerCountryInterface
Parameters
- $p_countryName : string
Return values
CustomerCountryInterface —findCountryZoneByNameAndCountry()
This method returns a CustomerCountryZone object if found. Otherwise null will be returned.
public
findCountryZoneByNameAndCountry(CustomerCountryZoneNameInterface|string $p_zoneName, CustomerCountryInterface $customerCountry) : CustomerCountryZoneInterface|null
Parameters
- $p_zoneName : CustomerCountryZoneNameInterface|string
- $customerCountry : CustomerCountryInterface
Return values
CustomerCountryZoneInterface|null —findCountryZoneByZoneCodeAndCountry()
Finds the country zone by the given zone code and country.
public
findCountryZoneByZoneCodeAndCountry(CustomerCountryZoneIsoCode $zoneCode, CustomerCountryInterface $country) : CustomerCountryZoneInterface|null
Null will be returned if no results are found.
Parameters
- $zoneCode : CustomerCountryZoneIsoCode
-
Zone code of expected country zone.
- $country : CustomerCountryInterface
-
Country of zone.
Return values
CustomerCountryZoneInterface|null —Country zone model.
findCountryZoneByZoneCodeAndCountryId()
Returns the country zone by the given zone code and country id.
public
findCountryZoneByZoneCodeAndCountryId(CustomerCountryZoneIsoCode $zoneCode, IdType $countryId) : CustomerCountryZoneInterface
Null will be returned if no results are found.
Parameters
- $zoneCode : CustomerCountryZoneIsoCode
-
Zone code of expected country zone.
- $countryId : IdType
-
Country id of zone.
Return values
CustomerCountryZoneInterface —Country zone model.
findCountryZonesByCountryId()
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
public
findCountryZonesByCountryId(IdType $countryId) : array<string|int, mixed>
Parameters
- $countryId : IdType
Return values
array<string|int, mixed> —of CustomerCountryZone objects
getCountries()
Getter method for all countries
public
getCountries() : CustomerCountryCollection
Return values
CustomerCountryCollection —getCountryById()
Getter method for the country ID
public
getCountryById(IdType $id) : CustomerCountryInterface
Parameters
- $id : IdType
Return values
CustomerCountryInterface —getCountryByIso2()
Get country by iso2 code.
public
getCountryByIso2(string $p_countryIso2) : CustomerCountryInterface
Parameters
- $p_countryIso2 : string
Return values
CustomerCountryInterface —getCountryByName()
Get country by name.
public
getCountryByName(string $p_countryName) : CustomerCountryInterface
Parameters
- $p_countryName : string
Return values
CustomerCountryInterface —getCountryZoneById()
public
getCountryZoneById(IdType $id) : CustomerCountryZoneInterface
Parameters
- $id : IdType
Return values
CustomerCountryZoneInterface —getCountryZoneByNameAndCountry()
Getter method for the country zone
public
getCountryZoneByNameAndCountry(CustomerCountryZoneNameInterface|string $p_zoneName, CustomerCountryInterface $customerCountry) : CustomerCountryZoneInterface
Parameters
- $p_zoneName : CustomerCountryZoneNameInterface|string
- $customerCountry : CustomerCountryInterface
Return values
CustomerCountryZoneInterface —getCountryZoneByZoneCodeAndCountry()
Returns the country zone by the given zone code and country.
public
getCountryZoneByZoneCodeAndCountry(CustomerCountryZoneIsoCode $zoneCode, CustomerCountryInterface $country) : CustomerCountryZoneInterface
An error will be raised if no results are found.
Parameters
- $zoneCode : CustomerCountryZoneIsoCode
-
Zone code of expected country zone.
- $country : CustomerCountryInterface
-
Country of zone.
Tags
Return values
CustomerCountryZoneInterface —Country zone model.
getCountryZoneByZoneCodeAndCountryId()
Returns the country zone by the given zone code and country id.
public
getCountryZoneByZoneCodeAndCountryId(CustomerCountryZoneIsoCode $zoneCode, IdType $countryId) : CustomerCountryZoneInterface
An error will be raised if no results are found.
Parameters
- $zoneCode : CustomerCountryZoneIsoCode
-
Zone code of expected country zone.
- $countryId : IdType
-
Country id of zone.
Tags
Return values
CustomerCountryZoneInterface —Country zone model.
getUnknownCountryZoneByName()
This method will return a new CustomerCountryZone object representing an unknown country zone.
public
getUnknownCountryZoneByName(string $p_zoneName) : CustomerCountryZone
Parameters
- $p_zoneName : string
Return values
CustomerCountryZone —isStateMandatory()
This method returns whether the specified country, necessary, needs a state.
public
isStateMandatory(IdType $countryId) : bool
Parameters
- $countryId : IdType