RsvCheckFrameHandler::supports()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.6111
c 0
b 0
f 0
cc 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\FrameHandler;
12
13
14
use Nekland\Woketo\Rfc6455\Frame;
15
use Nekland\Woketo\Rfc6455\Message;
16
use Nekland\Woketo\Rfc6455\MessageProcessor;
17
use React\Socket\ConnectionInterface;
18
19
class RsvCheckFrameHandler implements Rfc6455FrameHandlerInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24 2
    public function supports(Message $message)
25
    {
26 2
        foreach ($message->getFrames() as $frame) {
27 2
            if ($frame->getRsv1() || $frame->getRsv2() || $frame->getRsv3()) {
28 1
                return true;
29
            }
30
        }
31
32 1
        return false;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 1
    public function process(Message $message, MessageProcessor $messageProcessor, ConnectionInterface $socket)
39
    {
40 1
        $messageProcessor->write($messageProcessor->getFrameFactory()->createCloseFrame(Frame::CLOSE_PROTOCOL_ERROR), $socket);
41 1
        $socket->end();
42 1
    }
43
}
44