public function withAttribute($key, $value)
    {
        $newAttributes = $this->attributes->withAttribute($key, $value);

        $that = clone($this);
        $that->attributes = $newAttributes;

        return $that;
    }
public function withAttribute($key, $value)
    {
        $newAttributes = $this->attributes->withAttribute($key, $value);

        $that = clone($this);
        $that->attributes = $newAttributes;

        return $that;
    }
public function withAttribute ( $ key , $ value ) { $ newAttributes = $ this -> attributes -> withAttribute ( $ key , $ value ) ; $ that = clone ( $ this ) ; $ that -> attributes = $ newAttributes ; return $ that ; }
Returns a copy of the element with the attribute set.

Note: If the specified attribute is not legal on this element as
specified by the allowedAttributes property, the object will not be
changed and the same object will be returned.

@param string $key
The attribute to set.
@param string|array $value
The value to which to set it.

@return self
Returns a copy of the element with the attribute set .