RoomController::enterRoom()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: shanmaseen
5
 * Date: 26/03/19
6
 * Time: 10:57 ص
7
 */
8
9
namespace Shamaseen\Laravel\Ratchet\Controllers;
10
11
12
use Shamaseen\Laravel\Ratchet\Traits\RoomUtility;
13
14
class RoomController extends WebSocketController
15
{
16
    use RoomUtility;
17
18
    /**
19
     * @throws \Illuminate\Validation\ValidationException
20
     */
21
    function enterRoom()
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...
22
    {
23
        $this->validate($this->request,[
24
            'room_id'=>'required'
25
        ]);
26
        $room_id =$this->request->room_id;
0 ignored issues
show
Bug introduced by
The property room_id does not seem to exist in Illuminate\Support\Collection.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
27
28
        $this->validateRoom($room_id,true);
29
30
        $this->addMember($room_id);
31
    }
32
33
    /**
34
     * @throws \Illuminate\Validation\ValidationException
35
     */
36
    function exitRoom()
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...
37
    {
38
39
        $this->validate($this->request,[
40
            'room_id'=>'required'
41
        ]);
42
        $room_id =$this->request->room_id;
0 ignored issues
show
Bug introduced by
The property room_id does not seem to exist in Illuminate\Support\Collection.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
43
44
        $this->validateRoom($room_id);
45
46
        $this->removeMember($room_id);
47
    }
48
}