WebSocketError::setExtra()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Helix\Socket\WebSocket;
4
5
use RuntimeException;
6
use Throwable;
7
8
/**
9
 * A WebSocket error.
10
 *
11
 * Error codes less than `1000` are not used by the protocol or exposed to peers,
12
 * but may be used internally per implementation.
13
 *
14
 * @see https://tools.ietf.org/html/rfc6455#section-7.4
15
 */
16
class WebSocketError extends RuntimeException {
17
18
    /**
19
     * @var mixed
20
     */
21
    protected $extra;
22
23
    /**
24
     * @var Frame|null
25
     */
26
    protected $frame;
27
28
    public function __construct (int $code, string $message = '', Frame $frame = null, Throwable $previous = null) {
29
        parent::__construct($message, $code, $previous);
30
        $this->frame = $frame;
31
    }
32
33
    /**
34
     * @return mixed
35
     */
36
    public function getExtra () {
37
        return $this->extra;
38
    }
39
40
    /**
41
     * @return Frame|null
42
     */
43
    public function getFrame () {
44
        return $this->frame;
45
    }
46
47
    /**
48
     * @param mixed $extra
49
     * @return $this
50
     */
51
    public function setExtra ($extra) {
52
        $this->extra = $extra;
53
        return $this;
54
    }
55
56
}