a; } public function isComment(): bool { return self::TYPE_COMMENT === $this->a; } public function isCommentRecommendation(): bool { return self::TYPE_COMMENT_RECOMMENDATION === $this->a; } public function isPostRecommendation(): bool { return self::TYPE_POST_COMMENT_RECOMMENDATION === $this->a; } /** * @throws \RuntimeException * @throws UnsupportedTypeException */ public function isValid(): bool { switch ($this->a) { case self::TYPE_POST: if ( null !== $this->author && null !== $this->authorId && null !== $this->html && null !== $this->postId && null !== $this->private && null !== $this->tags ) { return true; } break; case self::TYPE_COMMENT; if ( null !== $this->author && null !== $this->authorId && null !== $this->commentId && null !== $this->html && null !== $this->postId && null !== $this->text ) { return true; } break; case self::TYPE_COMMENT_RECOMMENDATION; if ( null !== $this->author && null !== $this->authorId && null !== $this->postId ) { return true; } break; case null: throw new \RuntimeException('Message has NULL type.'); break; default: throw new UnsupportedTypeException(sprintf('Type \'%s\' is not supported.', $this->a)); } return false; } public function getA(): string { return $this->a; } public function getAuthor(): string { return $this->author; } public function getAuthorId(): int { return $this->authorId; } public function getAuthorName(): ?string { return $this->authorName; } public function getCommentId(): ?int { return $this->commentId; } public function getCut(): ?bool { return $this->cut; } public function getFiles(): ?array { return $this->files; } public function getHtml(): ?string { return $this->html; } public function getLink(): ?string { return $this->link; } public function getPostId(): string { return $this->postId; } public function getPostAuthorId(): ?int { return $this->postAuthorId; } public function getPrivate(): ?bool { return $this->private; } public function getRcid(): ?int { return $this->rcid; } public function getTags(): ?array { return $this->tags; } public function getText(): string { return $this->text; } public function getTitle(): ?string { return $this->title; } public function getToCommentId(): ?string { return $this->toCommentId; } public function getToText(): ?string { return $this->toText; } public function getToUsers(): ?array { return $this->toUsers; } }