Completed
Pull Request — master (#110)
by Charlotte
06:09
created

RsvCheckFrameHandler   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 19
ccs 0
cts 14
cp 0
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\Socket\ConnectionInterface;
18
19
class RsvCheckFrameHandler implements Rfc6455MessageHandlerInterface
20
{
21
    public function supports(Message $message)
22
    {
23
        foreach ($message->getFrames() as $frame) {
24
            if ($frame->getRsv1() || $frame->getRsv2() || $frame->getRsv3()) {
25
                return true;
26
            }
27
        }
28
29
        return false;
30
    }
31
32
    public function process(Message $message, MessageProcessor $messageProcessor, ConnectionInterface $socket)
33
    {
34
        $messageProcessor->write($messageProcessor->getFrameFactory()->createCloseFrame(Frame::CLOSE_PROTOCOL_ERROR), $socket);
35
        $socket->end();
36
    }
37
}
38