Pop\Dom\Child::setAttributes PHP Method

setAttributes() public method

Set an attribute or attributes for the child element object.
public setAttributes ( array | string $a, string $v = null ) : Child
$a array | string
$v string
return Child
    public function setAttributes($a, $v = null)
    {
        if (is_array($a)) {
            foreach ($a as $name => $value) {
                $this->attributes[$name] = $value;
            }
        } else {
            $this->attributes[$a] = $v;
        }
        return $this;
    }

Usage Example

Example #1
0
 public function testChild()
 {
     $c = new Child('p', 'This is a paragraph', new Child('p', 'This is another paragraph'));
     $c->setAttributes('class', 'some-class');
     $this->assertEquals('p', $c->getNodeName());
     $this->assertEquals('This is a paragraph', $c->getNodeValue());
     $this->assertEquals('some-class', $c->getAttribute('class'));
 }
All Usage Examples Of Pop\Dom\Child::setAttributes