WebSocketError   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 41
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getExtra() 0 3 1
A getFrame() 0 3 1
A setExtra() 0 4 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
}