Packet::setStream()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Thruster\Component\PacketHandler;
4
5
use Thruster\Component\Stream\Stream;
6
7
/**
8
 * Class Packet
9
 *
10
 * @package Thruster\Component\PacketHandler
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class Packet implements PacketInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @var array
22
     */
23
    protected $data;
24
25
    /**
26
     * @var Stream
27
     */
28
    protected $stream;
29
30
    /**
31
     * @var StreamHandler
32
     */
33
    protected $streamHandler;
34
35
    /**
36
     * @var bool
37
     */
38
    protected $propagationStopped;
39
40 4
    public function __construct(string $name, array $data = [])
41
    {
42 4
        $this->name = $name;
43 4
        $this->data = $data;
44 4
        $this->propagationStopped = false;
45 4
    }
46
47
    /**
48
     * @return string
49
     */
50 3
    public function getName() : string
51
    {
52 3
        return $this->name;
53
    }
54
55
    /**
56
     * @return array
57
     */
58 1
    public function getData() : array
59
    {
60 1
        return $this->data;
61
    }
62
63
    /**
64
     * @return Stream
65
     */
66 1
    public function getStream() : Stream
67
    {
68 1
        return $this->stream;
69
    }
70
71
    /**
72
     * @param Stream $stream
73
     *
74
     * @return $this
75
     */
76 1
    public function setStream(Stream $stream)
77
    {
78 1
        $this->stream = $stream;
79
80 1
        return $this;
81
    }
82
83
    /**
84
     * @return StreamHandler
85
     */
86 1
    public function getStreamHandler() : StreamHandler
87
    {
88 1
        return $this->streamHandler;
89
    }
90
91
    /**
92
     * @param StreamHandler $streamHandler
93
     *
94
     * @return $this
95
     */
96 3
    public function setStreamHandler(StreamHandler $streamHandler)
97
    {
98 3
        $this->streamHandler = $streamHandler;
99
100 3
        return $this;
101
    }
102
103 2
    public function isPropagationStopped() : bool
104
    {
105 2
        return $this->propagationStopped;
106
    }
107
108
    /**
109
     * @return $this
110
     */
111 1
    public function stopPropagation() : self
112
    {
113 1
        $this->propagationStopped = true;
114
115 1
        return $this;
116
    }
117
}
118