public function build() { if ($this->objectID == NULL) { $this->objectID = UOID::createUOID(); } if ($this->datetime == NULL) { $this->datetime = XSDDateTime::getXSDDateTime(); } if (!UOID::isValid($this->objectID)) { throw new IllegalModelStateException('Invalid objectID'); } if (!UOID::isValid($this->targetID)) { throw new IllegalModelStateException('Invalid targetID'); } if (!GID::isValid($this->author)) { throw new IllegalModelStateException('Invalid author'); } if ($this->body == '' || $this->body == NULL) { throw new IllegalModelStateException('Invalid body'); } if (!XSDDateTime::validateXSDDateTime($this->datetime)) { throw new IllegalModelStateException('Invalid datetime'); } $conversationMessage = new ConversationMessageObject($this); if ($conversationMessage->getSignature() == NULL) { $conversationMessage->signObject(); } if (!$conversationMessage->verifyObjectSignature()) { throw new IllegalModelStateException('Invalid signature'); } return $conversationMessage; }