ReadEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getFrame() 0 4 1
A isPartial() 0 4 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