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

RsvCheckFrameHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B 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\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