Skip to content

Commit f97c155

Browse files
committed
Frame type checking for encode()
1 parent 99755dd commit f97c155

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Wrench/Frame/HybiFrame.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class HybiFrame extends Frame
6464
*/
6565
public function encode($payload, $type = Protocol::TYPE_TEXT, $masked = false)
6666
{
67+
if (!is_int($type) || !in_array($type, Protocol::$frameTypes)) {
68+
throw new InvalidArgumentException('Invalid frame type');
69+
}
70+
6771
$this->type = $type;
6872
$this->masked = $masked;
6973
$this->payload = $payload;

0 commit comments

Comments
 (0)