1 | <?php |
||
2 | |||
3 | namespace BeyondCode\LaravelWebSockets\Server\Loggers; |
||
4 | |||
5 | use Ratchet\ConnectionInterface; |
||
6 | |||
7 | class ConnectionLogger extends Logger implements ConnectionInterface |
||
8 | { |
||
9 | /** |
||
10 | * The connection to watch. |
||
11 | * |
||
12 | * @var \Ratchet\ConnectionInterface |
||
13 | */ |
||
14 | protected $connection; |
||
15 | |||
16 | /** |
||
17 | * Create a new instance and add a connection to watch. |
||
18 | * |
||
19 | * @param \Ratchet\ConnectionInterface $connection |
||
20 | * @return self |
||
21 | */ |
||
22 | public static function decorate(ConnectionInterface $app): self |
||
23 | { |
||
24 | $logger = app(self::class); |
||
25 | |||
26 | return $logger->setConnection($app); |
||
0 ignored issues
–
show
|
|||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Set a new connection to watch. |
||
31 | * |
||
32 | * @param \Ratchet\ConnectionInterface $connection |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function setConnection(ConnectionInterface $connection) |
||
36 | { |
||
37 | $this->connection = $connection; |
||
38 | |||
39 | return $this; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Send data through the connection. |
||
44 | * |
||
45 | * @param string $data |
||
46 | * @return void |
||
47 | */ |
||
48 | public function send($data) |
||
49 | { |
||
50 | $socketId = $this->connection->socketId ?? null; |
||
0 ignored issues
–
show
|
|||
51 | |||
52 | $this->info("Connection id {$socketId} sending message {$data}"); |
||
53 | |||
54 | $this->connection->send($data); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Close the connection. |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | public function close() |
||
63 | { |
||
64 | $this->warn("Connection id {$this->connection->socketId} closing."); |
||
0 ignored issues
–
show
|
|||
65 | |||
66 | $this->connection->close(); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function __set($name, $value) |
||
73 | { |
||
74 | return $this->connection->$name = $value; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function __get($name) |
||
81 | { |
||
82 | return $this->connection->$name; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function __isset($name) |
||
89 | { |
||
90 | return isset($this->connection->$name); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function __unset($name) |
||
97 | { |
||
98 | unset($this->connection->$name); |
||
99 | } |
||
100 | } |
||
101 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.