public function addElement($elementName, $content, array $attributes = null, $overwrite = FALSE, $allowMultiple = FALSE)
{
if (empty($elementName)) {
throw new \InvalidArgumentException('The element name may not be empty or NULL.');
}
if (!is_string($elementName)) {
throw new \InvalidArgumentException('The element name must be a string.');
}
$key = $elementName;
// return if element already exists & if overwriting is disabled
// & if multiple elements are not allowed.
if (isset($this->elements[$elementName]) && !$overwrite) {
if (!$allowMultiple) {
return $this;
}
$key .= '-' . $this->cpt();
}
$this->elements[$key]['name'] = $elementName;
$this->elements[$key]['content'] = $content;
$this->elements[$key]['attributes'] = $attributes;
return $this;
}