Context::setUnreadData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
/**
13
 * Class Context
14
 */
15
class Context
16
{
17
    /**
18
     * Unread data in socket
19
     *
20
     * @var string[]
21
     */
22
    private $unreadData = ['', ''];
23
24
    /**
25
     * Return UnreadData
26
     *
27
     * @param bool $isOutOfBand Flag if it is out of band data
28
     *
29
     * @return string
30
     */
31 44
    public function getUnreadData($isOutOfBand = false)
32
    {
33 44
        return $this->unreadData[(int) (bool) $isOutOfBand];
34
    }
35
36
    /**
37
     * Sets UnreadData
38
     *
39
     * @param string $unreadData New value for UnreadData
40
     * @param bool $isOutOfBand Flag if it is out of band data
41
     *
42
     * @return void
43
     */
44 43
    public function setUnreadData($unreadData, $isOutOfBand = false)
45
    {
46 43
        $this->unreadData[(int) (bool) $isOutOfBand] = $unreadData;
47 43
    }
48
49
    /**
50
     * Resets socket context
51
     *
52
     * @return void
53
     */
54 60
    public function reset()
55
    {
56 60
        $this->unreadData = ['', ''];
57 60
    }
58
}
59