public function setBase($base)
{
// Typecast base to string in case we've been given
// an instance of the distinguished name object.
$base = (string) $base;
// If the base DN isn't null we'll try to explode it.
$base = Utilities::explodeDn($base, false) ?: [];
// Remove the count key from the exploded distinguished name.
unset($base['count']);
foreach ($base as $key => $rdn) {
// We'll break the RDN into pieces
$pieces = explode('=', $rdn) ?: [];
// If there's exactly 2 pieces, then we can work with it.
if (count($pieces) === 2) {
$attribute = ucfirst($pieces[0]);
$method = 'add' . $attribute;
if (method_exists($this, $method)) {
// We see what type of RDN it is and add each accordingly.
call_user_func_array([$this, $method], [$pieces[1]]);
}
}
}
return $this;
}