Example #1
0
 /**
  * @param $element
  * @param array $attributes
  * @throws InvalidAttributeException
  */
 private function _set_attributes(Element &$element, array $attributes = null)
 {
     if (!is_null($attributes) && count($attributes) > 0) {
         foreach ($attributes as $attribute) {
             try {
                 $attr = preg_split('/:/', $attribute, 0, PREG_SPLIT_NO_EMPTY);
                 if (count($attr) != 2) {
                     throw new InvalidAttributeException('Invalid attribute - ' . $attribute);
                 }
                 $element->setAttribute($attr[0], $attr[1]);
             } catch (\Exception $ex) {
                 throw new InvalidAttributeException('Invalid attribute - ' . $attribute);
             }
         }
     }
 }
 public function setAttribute($attribute, $value)
 {
     $this->element->setAttribute($attribute, $value);
     return $this->htmlElement->setProperty($attribute, $value);
 }