Room   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addMember() 0 4 1
A removeMember() 0 4 1
A hasMember() 0 7 2
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
}