public function withUnique(Attribute $attr): self
    {
        $obj = clone $this;
        $obj->_attributes = array_filter($obj->_attributes,
            function (Attribute $a) use ($attr) {
                return $a->oid() != $attr->oid();
            });
        $obj->_attributes[] = $attr;
        return $obj;
    }
public function withUnique(Attribute $attr): self
    {
        $obj = clone $this;
        $obj->_attributes = array_filter($obj->_attributes,
            function (Attribute $a) use ($attr) {
                return $a->oid() != $attr->oid();
            });
        $obj->_attributes[] = $attr;
        return $obj;
    }
public function withUnique ( Attribute $ attr ) : self { $ obj = clone $ this ; $ obj -> _attributes = array_filter ( $ obj -> _attributes , function ( Attribute $ a ) use ( $ attr ) { return $ a -> oid ( ) != $ attr -> oid ( ) ; } ) ; $ obj -> _attributes [ ] = $ attr ; return $ obj ; }
Get self with single unique attribute added.

All previous attributes of the same type are removed.

@param Attribute $attr
@return self
Get self with single unique attribute added .