DatagramMemorizedIo::readRawDataIntoPicker()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 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