Passed
Push — master ( 6ac744...48d05f )
by Mohammad
07:18
created

ChatController::sendMessageToRoom()   A

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: 12:17 م
7
 */
8
9
namespace Shamaseen\Laravel\Ratchet\Controllers;
10
11
12
use Shamaseen\Laravel\Ratchet\Traits\RoomUtility;
13
14
class ChatController extends WebSocketController
15
{
16
17
    use RoomUtility;
18
    /**
19
     * @throws \Illuminate\Validation\ValidationException
20
     */
21
    function sendMessageToUser()
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...
Coding Style Naming introduced by
The variable $user_id is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
22
    {
23
        $this->validate($this->request,[
24
            'user_id'=>'required',
25
            'message' => 'required'
26
        ]);
27
        $user_id = $this->request->user_id;
28
        $message = $this->request->message;
29
30
        $this->sendToUser($user_id,$message);
31
    }
32
33
    /**
34
     * @throws \Illuminate\Validation\ValidationException
35
     */
36
    function sendMessageToRoom()
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...
Coding Style Naming introduced by
The variable $room_id is not named in camelCase.

This check marks variable names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
37
    {
38
        $this->validate($this->request,[
39
            'room_id'=>'required',
40
            'message' => 'required'
41
        ]);
42
        $room_id = $this->request->room_id;
43
        $message = $this->request->message;
44
45
        $this->sendToRoom($room_id,$message);
46
    }
47
}