ReadEvent::isPartial()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 0
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\Event;
11
12
use AsyncSockets\Frame\FrameInterface;
13
use AsyncSockets\Frame\PartialFrame;
14
use AsyncSockets\RequestExecutor\RequestExecutorInterface;
15
use AsyncSockets\Socket\SocketInterface;
16
17
/**
18
 * Class ReadEvent
19
 */
20
class ReadEvent extends IoEvent
21
{
22
    /**
23
     * Data read from network
24
     *
25
     * @var FrameInterface
26
     */
27
    private $frame;
28
29
    /**
30
     * Constructor
31
     *
32
     * @param RequestExecutorInterface $executor Request executor object
33
     * @param SocketInterface          $socket Socket for this request
34
     * @param mixed                    $context Any optional user data for event
35
     * @param FrameInterface           $frame Network data for read operation
36
     * @param bool                     $isOutOfBand Flag if data are out of band
37
     */
38 57
    public function __construct(
39
        RequestExecutorInterface $executor,
40
        SocketInterface $socket,
41
        $context,
42
        FrameInterface $frame,
43
        $isOutOfBand = false
44
    ) {
45 57
        parent::__construct($executor, $socket, $context, $isOutOfBand ? EventType::OOB : EventType::READ);
46 57
        $this->frame = $frame;
47 57
    }
48
49
    /**
50
     * Return response frame
51
     *
52
     * @return FrameInterface
53
     */
54 9
    public function getFrame()
55
    {
56 9
        return $this->frame;
57
    }
58
59
    /**
60
     * Return true, if frame in this event is partial
61
     *
62
     * @return bool
63
     */
64 3
    public function isPartial()
65
    {
66 3
        return $this->frame instanceof PartialFrame;
67
    }
68
}
69