/**
* Sets an attributes value by the specified key and sub-key.
*
* @param int|string $key
* @param mixed $value
* @param int|string $subKey
*
* @return $this
*/
public function setAttribute($key, $value, $subKey = null)
{
// Normalize key.
$key = $this->normalizeAttributeKey($key);
// If the key is equal to 'dn', we'll automatically
// change it to the full attribute name.
$key = $key == 'dn' ? $this->schema->distinguishedName() : $key;
if (is_null($subKey)) {
$this->attributes[$key] = is_array($value) ? $value : [$value];
} else {
$this->attributes[$key][$subKey] = $value;
}
return $this;
}