DatagramMemorizedIo   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A readRawDataIntoPicker() 0 6 1
1
<?php
2
/**
3
 * Async sockets
4
 *
5
 * @copyright Copyright (c) 2015-2017, Efimov Evgenij <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
namespace AsyncSockets\Socket\Io;
11
12
use AsyncSockets\Frame\FramePickerInterface;
13
use AsyncSockets\Socket\SocketInterface;
14
15
/**
16
 * Class DatagramMemorizedIo
17
 */
18
class DatagramMemorizedIo extends DatagramClientIo
19
{
20
    /**
21
     * Data for this socket
22
     *
23
     * @var string
24
     */
25
    private $data;
26
27
    /**
28
     * Constructor
29
     *
30
     * @param SocketInterface $socket Socket object
31
     * @param string          $remoteAddress Destination address in form scheme://host:port
32
     * @param string          $data Datagram for this socket
33
     */
34 34
    public function __construct(SocketInterface $socket, $remoteAddress, $data)
35
    {
36 34
        parent::__construct($socket, $remoteAddress);
37 34
        $this->data = (string) $data;
38 34
    }
39
40
    /** {@inheritdoc} */
41 1
    protected function readRawDataIntoPicker(FramePickerInterface $picker, $isOutOfBand)
42
    {
43 1
        $data       = $this->data;
44 1
        $this->data = '';
45 1
        return $picker->pickUpData($data, $this->remoteAddress);
46
    }
47
}
48