Completed
Push — master ( 104e68...b4839f )
by Maxime
12s
created

RsvCheckFrameHandler::supports()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 8.8571
cc 5
eloc 5
nc 3
nop 1
crap 5
1
<?php
2
/**
3
 * This file is a part of Woketo package.
4
 *
5
 * (c) Nekland <[email protected]>
6
 *
7
 * For the full license, take a look to the LICENSE file
8
 * on the root directory of this project
9
 */
10
11
namespace Nekland\Woketo\Rfc6455\MessageHandler;
12
13
14
use Nekland\Woketo\Rfc6455\Frame;
15
use Nekland\Woketo\Rfc6455\Message;
16
use Nekland\Woketo\Rfc6455\MessageProcessor;
17
use React\Stream\Stream;
18
19
class RsvCheckFrameHandler implements Rfc6455MessageHandlerInterface
20
{
21 2
    public function supports(Message $message)
22
    {
23 2
        foreach ($message->getFrames() as $frame) {
24 2
            if ($frame->getRsv1() || $frame->getRsv2() || $frame->getRsv3()) {
25 2
                return true;
26
            }
27
        }
28
29 1
        return false;
30
    }
31
32 1
    public function process(Message $message, MessageProcessor $messageProcessor, Stream $socket)
33
    {
34 1
        $messageProcessor->write($messageProcessor->getFrameFactory()->createCloseFrame(Frame::CLOSE_PROTOCOL_ERROR), $socket);
35 1
        $socket->end();
36 1
    }
37
}
38