id = $id; } public function toInt(): int { return $this->id; } private static function ensureIsValid(int $id) { if ($id <= 0) { throw new InvalidArgumentException('Invalid PostId given'); } } }