Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 18 |
CRAP | |
0.00% |
0 / 1 |
| SocketHeader | |
0.00% |
0 / 18 |
|
0.00% |
0 / 18 |
380 | |
0.00% |
0 / 1 |
| getSendFrom | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSendFrom | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSendTo | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSendTo | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLength | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setLength | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSubtype | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSubtype | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| unserialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getProtocolVersion | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| set | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| has | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| generate | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\Message\Socket |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\Message\Socket; |
| 16 | |
| 17 | use phpOMS\Contract\SerializableInterface; |
| 18 | use phpOMS\Message\HeaderAbstract; |
| 19 | |
| 20 | /** |
| 21 | * Server class. |
| 22 | * |
| 23 | * Parsing/serializing arrays to and from php file |
| 24 | * |
| 25 | * @package phpOMS\Message\Socket |
| 26 | * @license OMS License 2.0 |
| 27 | * @link https://jingga.app |
| 28 | * @since 1.0.0 |
| 29 | */ |
| 30 | class SocketHeader extends HeaderAbstract implements SerializableInterface |
| 31 | { |
| 32 | private $sendFrom = null; |
| 33 | |
| 34 | private $sendTo = null; |
| 35 | |
| 36 | /** |
| 37 | * Packet size. |
| 38 | * |
| 39 | * @var int |
| 40 | * @since 1.0.0 |
| 41 | */ |
| 42 | private $length = 0; |
| 43 | |
| 44 | /** |
| 45 | * Packet type. |
| 46 | * |
| 47 | * @var int |
| 48 | * @since 1.0.0 |
| 49 | */ |
| 50 | private $type = 0; |
| 51 | |
| 52 | /** |
| 53 | * Packet subtype. |
| 54 | * |
| 55 | * @var int |
| 56 | * @since 1.0.0 |
| 57 | */ |
| 58 | private $subtype = 0; |
| 59 | |
| 60 | /** |
| 61 | * Header. |
| 62 | * |
| 63 | * @var string[][] |
| 64 | * @since 1.0.0 |
| 65 | */ |
| 66 | private array $header = []; |
| 67 | |
| 68 | /** |
| 69 | * Get the sender |
| 70 | * |
| 71 | * @return mixed |
| 72 | * |
| 73 | * @since 1.0.0 |
| 74 | */ |
| 75 | public function getSendFrom() |
| 76 | { |
| 77 | return $this->sendFrom; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Set sender |
| 82 | * |
| 83 | * @param mixed $sendFrom Sender |
| 84 | * |
| 85 | * @return void |
| 86 | * |
| 87 | * @since 1.0.0 |
| 88 | */ |
| 89 | public function setSendFrom($sendFrom) : void |
| 90 | { |
| 91 | $this->sendFrom = $sendFrom; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Get receiver |
| 96 | * |
| 97 | * @return mixed |
| 98 | * |
| 99 | * @since 1.0.0 |
| 100 | */ |
| 101 | public function getSendTo() |
| 102 | { |
| 103 | return $this->sendTo; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Set receiver |
| 108 | * |
| 109 | * @param mixed $sendTo Receiver |
| 110 | * |
| 111 | * @return void |
| 112 | * |
| 113 | * @since 1.0.0 |
| 114 | */ |
| 115 | public function setSendTo($sendTo) : void |
| 116 | { |
| 117 | $this->sendTo = $sendTo; |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * @return int |
| 122 | * |
| 123 | * @since 1.0.0 |
| 124 | */ |
| 125 | public function getLength() |
| 126 | { |
| 127 | return $this->length; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Set header length |
| 132 | * |
| 133 | * @param int $length Header length |
| 134 | * |
| 135 | * @return void |
| 136 | * |
| 137 | * @since 1.0.0 |
| 138 | */ |
| 139 | public function setLength($length) : void |
| 140 | { |
| 141 | $this->length = $length; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Get package type |
| 146 | * |
| 147 | * @return int |
| 148 | * |
| 149 | * @since 1.0.0 |
| 150 | */ |
| 151 | public function getType() : int |
| 152 | { |
| 153 | return $this->type; |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Set package type |
| 158 | * |
| 159 | * @param int $type Type |
| 160 | * |
| 161 | * @return void |
| 162 | * |
| 163 | * @since 1.0.0 |
| 164 | */ |
| 165 | public function setType(int $type) : void |
| 166 | { |
| 167 | $this->type = $type; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Get subtype |
| 172 | * |
| 173 | * @return int |
| 174 | * |
| 175 | * @since 1.0.0 |
| 176 | */ |
| 177 | public function getSubtype() : int |
| 178 | { |
| 179 | return $this->subtype; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Set subtype |
| 184 | * |
| 185 | * @param int $subtype Subtype |
| 186 | * |
| 187 | * @return void |
| 188 | * |
| 189 | * @since 1.0.0 |
| 190 | */ |
| 191 | public function setSubtype($subtype) : void |
| 192 | { |
| 193 | $this->subtype = $subtype; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Serializing header. |
| 198 | * |
| 199 | * @return string Json serialization |
| 200 | * |
| 201 | * @since 1.0.0 |
| 202 | */ |
| 203 | public function serialize() : string |
| 204 | { |
| 205 | return ''; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Jsonfy object. |
| 210 | * |
| 211 | * @return string Json serialization |
| 212 | * |
| 213 | * @since 1.0.0 |
| 214 | */ |
| 215 | public function __toString() |
| 216 | { |
| 217 | return ''; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Unserializing json string. |
| 222 | * |
| 223 | * @param string $string String to unserialize |
| 224 | * |
| 225 | * @return void |
| 226 | * |
| 227 | * @since 1.0.0 |
| 228 | */ |
| 229 | public function unserialize(mixed $string) : void |
| 230 | { |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * {@inheritdoc} |
| 235 | */ |
| 236 | public function getProtocolVersion() : string |
| 237 | { |
| 238 | return 'Socket/1.1'; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * {@inheritdoc} |
| 243 | */ |
| 244 | public function set(string $key, string $header, bool $overwrite = false) : bool |
| 245 | { |
| 246 | return true; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * {@inheritdoc} |
| 251 | */ |
| 252 | public function get(string $key = null) : array |
| 253 | { |
| 254 | return $key === null ? $this->header : ($this->header[\strtolower($key)] ?? []); |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * {@inheritdoc} |
| 259 | */ |
| 260 | public function has(string $key) : bool |
| 261 | { |
| 262 | return isset($this->header[$key]); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * {@inheritdoc} |
| 267 | */ |
| 268 | public function generate(int $code) : void |
| 269 | { |
| 270 | } |
| 271 | } |