LdapTools\Resolver\AttributeValueResolver::convert PHP Method

convert() protected method

Perform the attribute conversion process.
protected convert ( array $attributes, boolean $toLdap = true ) : array
$attributes array
$toLdap boolean
return array
    protected function convert(array $attributes, $toLdap = true)
    {
        $direction = $toLdap ? 'toLdap' : 'fromLdap';
        foreach ($attributes as $attribute => $values) {
            // No converter, but the value should still be encoded.
            if (!$this->schema->hasConverter($attribute) && !isset($this->converted[$attribute])) {
                $attributes[$attribute] = $this->encodeValues($values);
                // Only continue if it has a converter and has not already been converted.
            } elseif ($this->schema->hasConverter($attribute) && !isset($this->converted[$attribute])) {
                $values = $this->getConvertedValues($values, $attribute, $direction);
                if (in_array($attribute, $this->aggregated)) {
                    $attribute = $this->schema->getAttributeToLdap($attribute);
                }
                $attributes[$attribute] = count($values) == 1 ? reset($values) : $values;
            }
        }
        return $this->removeValuesFromEntry($attributes, array_merge($this->aggregated, $this->remove));
    }