You are here

public function UcAddressesSchemaAddress::compareAddress in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 class/UcAddressesSchemaAddress.class.php \UcAddressesSchemaAddress::compareAddress()

Checks if the schema address of the given address is equal to the schema address of this.

@access public

Parameters

UcAddressesSchemaAddress $address: The address to compare against.

Return value

boolean TRUE if the addresses are considered equal. FALSE otherwise.

File

class/UcAddressesSchemaAddress.class.php, line 525
Contains the UcAddressesSchemaAddress class.

Class

UcAddressesSchemaAddress
The schema address class.

Code

public function compareAddress(UcAddressesSchemaAddress $address) {
  static $fields_to_compare = array();
  if ($address === $this) {

    // No comparison needed. Given address object is exactly the same.
    return TRUE;
  }
  $fieldsDataThisAddress = $this
    ->getRawFieldData();
  $fieldsDataOtherAddress = $address
    ->getRawFieldData();

  // Find out which field to compare.
  if (count($fields_to_compare) < 1) {
    $fields_data = self::getDefinedFields();
    foreach ($fields_data as $fieldName => $field_data) {
      if ($field_data['compare']) {
        $fields_to_compare[] = $fieldName;
      }
    }
  }
  foreach ($fields_to_compare as $fieldName) {
    if ($fieldsDataThisAddress[$fieldName] != $fieldsDataOtherAddress[$fieldName]) {
      return FALSE;
    }
  }
  return TRUE;
}