public function setAttribute( $attr, $value ) {
        //data-* attribute or in valid attribute array
        if( strpos( $attr, 'data-' ) === 0 || in_array( $attr, $this->validAttributes ) ) {
            $this->attrs[$attr] = $value;
        } else {
            throw new Exception\InvalidAttributeException( $attr );
        }
    }
public function setAttribute( $attr, $value ) {
        //data-* attribute or in valid attribute array
        if( strpos( $attr, 'data-' ) === 0 || in_array( $attr, $this->validAttributes ) ) {
            $this->attrs[$attr] = $value;
        } else {
            throw new Exception\InvalidAttributeException( $attr );
        }
    }
public function setAttribute ( $ attr , $ value ) { //data-* attribute or in valid attribute array
 if ( strpos ( $ attr , 'data-' ) === 0 || in_array ( $ attr , $ this -> validAttributes ) ) { $ this -> attrs [ $ attr ] = $ value ; } else { throw new Exception \ InvalidAttributeException ( $ attr ) ; } }
Sets an attribute given the name and value.

@param $attr the name of the attribute
@param $value the value of the attribute

@throws Exception\InvalidAttributeException if an invalid attribute is provided
Sets an attribute given the name and value .