PingFrameHandler::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
use Nekland\Woketo\Rfc6455\Frame;
14
use Nekland\Woketo\Rfc6455\Message;
15
use Nekland\Woketo\Rfc6455\MessageProcessor;
16
use React\Socket\ConnectionInterface;
17
18
class PingFrameHandler implements Rfc6455FrameHandlerInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 2
    public function supports(Message $message)
24
    {
25 2
        return $message->getFirstFrame()->getOpcode() === Frame::OP_PING;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 2
    public function process(Message $message, MessageProcessor $messageProcessor, ConnectionInterface $socket)
32
    {
33 2
        $messageProcessor->write($messageProcessor->getFrameFactory()->createPongFrame($message->getContent()), $socket);
34 2
    }
35
}
36