LdapTools\AttributeConverter\ConvertExchangeProxyAddress::modifyDefaultAddress PHP Метод

modifyDefaultAddress() защищенный Метод

Modifies the existing list of addresses to set the default for a specific address type.
protected modifyDefaultAddress ( string $defaultAddress )
$defaultAddress string
    protected function modifyDefaultAddress($defaultAddress)
    {
        $values = is_array($this->getLastValue()) ? $this->getLastValue() : [$this->getLastValue()];
        $addressType = $this->getArrayValue($this->getOptions()['addressType'], $this->getAttribute());
        $isAddressInArray = in_array(MBString::strtolower($defaultAddress), MBString::array_change_value_case($values));
        $length = strlen($addressType);
        foreach ($values as $index => $address) {
            // If another address is already the default then it must be changed.
            if (substr($address, 0, $length) === strtoupper($addressType) && $address !== $defaultAddress) {
                $values[$index] = substr_replace($address, $addressType, 0, $length);
                // If the address is the one we are looking for but is not the default, then make it the default.
            } elseif ($isAddressInArray && MBString::strtolower($address) == MBString::strtolower($defaultAddress)) {
                $values[$index] = $defaultAddress;
            }
        }
        // It was not already an address in the array, and the other default would have been changed now.
        if (!in_array($defaultAddress, $values)) {
            $values[] = $defaultAddress;
        }
        $this->setLastValue($values);
    }