RsvCheckFrameHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 10 5
A process() 0 5 1
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