public function setId(int $objectId): int
    {
        if ($this->objectId !== 0) {
            throw new UnexpectedValueException('ObjectId property is immutable.');
        }

        $this->objectId = $objectId;
        $this->rId = $objectId;

        return $objectId;
    }
public function setId(int $objectId): int
    {
        if ($this->objectId !== 0) {
            throw new UnexpectedValueException('ObjectId property is immutable.');
        }

        $this->objectId = $objectId;
        $this->rId = $objectId;

        return $objectId;
    }
public function setId ( int $ objectId ) : int { if ( $ this -> objectId !== 0 ) { throw new UnexpectedValueException ( 'ObjectId property is immutable.' ) ; } $ this -> objectId = $ objectId ; $ this -> rId = $ objectId ; return $ objectId ; }
Set the id for the object.

<pre><code class="php">$object = new DomainObject($dependencies);

$object->setId(5);
</code></pre>

@param int $objectId New object id.

@throws UnexpectedValueException If the id on the object is already set.

@return int New object id.
Set the id for the object .