puiu91
2/26/2016 - 2:48 PM

gistfile1.txt

class elementCreator {

  public $element;

  public static function createElemenet(DOMDocument $dom, $tag, $attributes = null) {
    $element = $DOM->createElement($tag);

    if ($attributes) {
      foreach ($attributes as $attribute => $value) {
        $element->setAttribute($attribute, $value);
      }
    }

    $this->element = $element;

    return $this;
  }

  public static function setValue($value) {
    $this->element->setAttribute('value', $value);
    return $this->element;
  }

}