Completed
Branch master (1d1574)
by Evgenij
18:38
created

ReadEvent::getFrame()   A

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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Async sockets
4
 *
5
 * @copyright Copyright (c) 2015-2016, 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
     */
37 39
    public function __construct(
38
        RequestExecutorInterface $executor,
39
        SocketInterface $socket,
40
        $context,
41
        FrameInterface $frame
42
    ) {
43 39
        parent::__construct($executor, $socket, $context, EventType::READ);
44 39
        $this->frame = $frame;
45 39
    }
46
47
    /**
48
     * Return response frame
49
     *
50
     * @return FrameInterface
51
     */
52 4
    public function getFrame()
53
    {
54 4
        return $this->frame;
55
    }
56
57
    /**
58
     * Return true, if frame in this event is partial
59
     *
60
     * @return bool
61
     */
62 3
    public function isPartial()
63
    {
64 3
        return $this->frame instanceof PartialFrame;
65
    }
66
}
67