Client::removeOnCloseRoute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: hammo
5
 * Date: 11/13/2018
6
 * Time: 11:22 AM
7
 */
8
9
namespace Shamaseen\Laravel\Ratchet\Objects\Clients;
10
11
12
use Ratchet\ConnectionInterface;
13
use Shamaseen\Laravel\Ratchet\Traits\WebSocketMessagesManager;
14
15
/**
16
 * this class represent ratchet client
17
 * Class Client
18
 * @package App\WebSockets\Clients
19
 */
20
class Client
21
{
22
23
    use WebSocketMessagesManager;
24
    /**
25
     * this id is the laravel auth id
26
     * @var null|int $id
27
     */
28
    public $id = null;
29
30
    /** @var ConnectionInterface $conn */
31
    public $conn = null;
32
33
    /**
34
     * @var array
35
     */
36
    public $rooms = [];
37
38
    public $onCloseRoutes = [];
39
40
    public $session = null;
41
42
    /**
43
     * @param string $route
44
     * @return Client
45
     */
46
    function onClose(string $route)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
47
    {
48
       array_push($this->onCloseRoutes,$route);
49
50
        return $this;
51
    }
52
53
    function removeOnCloseRoute(string $route)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
54
    {
55
        if (($key = array_search($route, $this->onCloseRoutes)) !== false) {
56
            unset($this->onCloseRoutes[$key]);
57
        }
58
    }
59
}
60