setAttribute() public method

Set an attribute for this tag.
public setAttribute ( string $key, string | array $value )
$key string
$value string | array
Example #1
0
 public function testSetAttributeNoArray()
 {
     $tag = new Tag('a');
     $tag->setAttribute('href', 'http://google.com');
     $attribute = $tag->getAttribute('href');
     $this->assertEquals('http://google.com', $attribute['value']);
 }
Example #2
0
 /**
  * A wrapper method that simply calls the setAttribute method
  * on the tag of this node.
  *
  * @param string $key
  * @param string $value
  * @return $this
  */
 public function setAttribute($key, $value)
 {
     $this->tag->setAttribute($key, $value);
     return $this;
 }