public function build()
{
$filtered = array_diff(array_map('trim', $this->values), ['']);
if (is_null($this->original)) {
// If the original value is null, we'll assume
// that the attribute doesn't exist yet.
if (!empty($filtered)) {
// If the filtered array is not empty, we'll
// assume the developer is looking to
// add attributes to the model.
$this->setType(LDAP_MODIFY_BATCH_ADD);
}
// If the filtered array is empty and there is no original
// value, then we can ignore this attribute since
// we can't push null values to AD.
} else {
if (empty($filtered)) {
// If there's an original value and the array is
// empty then we can assume the developer is
// looking to completely remove all values
// of the specified attribute.
$this->setType(LDAP_MODIFY_BATCH_REMOVE_ALL);
} else {
// If the array isn't empty then we can assume the
// developer is trying to replace all attributes.
$this->setType(LDAP_MODIFY_BATCH_REPLACE);
}
}
return $this;
}