Room::addMember()   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
 * Created by PhpStorm.
4
 * User: shanmaseen
5
 * Date: 26/03/19
6
 * Time: 10:46 ص
7
 */
8
9
namespace Shamaseen\Laravel\Ratchet\Objects\Rooms;
10
11
use Shamaseen\Laravel\Ratchet\Objects\Clients\Client;
12
13
class Room
14
{
15
16
    public $id;
17
18
    /**
19
     * @var Client[]
20
     */
21
    public $members = [];
22
23
24
    public function __construct($id)
25
    {
26
        $this->id = $id;
27
    }
28
29
    /**
30
     * @param Client $client
31
     */
32
    function addMember($client)
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...
33
    {
34
        $this->members[$client->id] = $client;
35
    }
36
37
    /**
38
     * @param Client $client
39
     */
40
    function removeMember($client)
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...
41
    {
42
        unset($this->members[$client->id]);
43
    }
44
45
    function hasMember($client)
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...
46
    {
47
        if(array_key_exists($client->id,$this->members))
48
            return true;
49
50
        return false;
51
    }
52
}