PHP Class CommerceGuys\Addressing\Validator\Constraints\AddressFormatConstraintValidator

Inheritance: extends Symfony\Component\Validator\ConstraintValidator
Show file Open project: commerceguys/addressing

Protected Properties

Property Type Description
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface The address format repository.
$subdivisionRepository CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface The subdivision repository.

Public Methods

Method Description
__construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository = null, CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface $subdivisionRepository = null ) Creates an AddressFormatValidator instance.
validate ( $value, Constraint $constraint )

Protected Methods

Method Description
addViolation ( string $field, string $message, mixed $invalidValue, AddressFormat $addressFormat ) Adds a violation.
extractAddressValues ( CommerceGuys\Addressing\AddressInterface $address ) : array Extracts the address values.
validateFields ( array $values, AddressFormat $addressFormat, Constraint $constraint ) Validates the provided field values.
validatePostalCode ( string $postalCode, array $subdivisions, AddressFormat $addressFormat, Constraint $constraint ) Validates the provided postal code.
validateSubdivisions ( array $values, AddressFormat $addressFormat, Constraint $constraint ) : array Validates the provided subdivision values.

Method Details

__construct() public method

Creates an AddressFormatValidator instance.
public __construct ( CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface $addressFormatRepository = null, CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface $subdivisionRepository = null )
$addressFormatRepository CommerceGuys\Addressing\AddressFormat\AddressFormatRepositoryInterface
$subdivisionRepository CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface

addViolation() protected method

Accounts for differences between Symfony versions.
protected addViolation ( string $field, string $message, mixed $invalidValue, AddressFormat $addressFormat )
$field string The field.
$message string The error message.
$invalidValue mixed The invalid, validated value.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.

extractAddressValues() protected method

Extracts the address values.
protected extractAddressValues ( CommerceGuys\Addressing\AddressInterface $address ) : array
$address CommerceGuys\Addressing\AddressInterface The address.
return array An array of values keyed by field constants.

validate() public method

public validate ( $value, Constraint $constraint )
$constraint Symfony\Component\Validator\Constraint

validateFields() protected method

Validates the provided field values.
protected validateFields ( array $values, AddressFormat $addressFormat, Constraint $constraint )
$values array The field values, keyed by field constants.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
$constraint Symfony\Component\Validator\Constraint The constraint.

validatePostalCode() protected method

Validates the provided postal code.
protected validatePostalCode ( string $postalCode, array $subdivisions, AddressFormat $addressFormat, Constraint $constraint )
$postalCode string The postal code.
$subdivisions array An array of found valid subdivisions.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
$constraint Symfony\Component\Validator\Constraint The constraint.

validateSubdivisions() protected method

Validates the provided subdivision values.
protected validateSubdivisions ( array $values, AddressFormat $addressFormat, Constraint $constraint ) : array
$values array The field values, keyed by field constants.
$addressFormat CommerceGuys\Addressing\AddressFormat\AddressFormat The address format.
$constraint Symfony\Component\Validator\Constraint The constraint.
return array An array of found valid subdivisions.

Property Details

$addressFormatRepository protected property

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

$subdivisionRepository protected property

The subdivision repository.
protected SubdivisionRepositoryInterface,CommerceGuys\Addressing\Subdivision $subdivisionRepository
return CommerceGuys\Addressing\Subdivision\SubdivisionRepositoryInterface