From ac0d905ce4a888f1fc9c348002372e4d2cdbb71a Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Mon, 25 Feb 2019 19:12:52 +0300 Subject: [PATCH] Implementing 'rec' type validation in WebSocket\Message. --- .../PointToolsBundle/DTO/Api/WebSocket/Message.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/WebSocket/Message.php b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/WebSocket/Message.php index ba2ee4d..6cd6229 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/WebSocket/Message.php +++ b/src/Skobkin/Bundle/PointToolsBundle/DTO/Api/WebSocket/Message.php @@ -12,7 +12,7 @@ class Message implements ValidableInterface { public const TYPE_COMMENT = 'comment'; public const TYPE_POST = 'post'; - public const TYPE_POST_RECOMMENDATION = 'rec'; + public const TYPE_POST_COMMENT_RECOMMENDATION = 'rec'; public const TYPE_COMMENT_RECOMMENDATION = 'ok'; /** @@ -187,6 +187,17 @@ class Message implements ValidableInterface } break; + case self::TYPE_POST_COMMENT_RECOMMENDATION; + if ( + null !== $this->author && + null !== $this->authorId && + null !== $this->postId && + null !== $this->postAuthorId + ) { + return true; + } + break; + case null: throw new \RuntimeException('Message has NULL type.'); break;