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

ReadEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

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