GenerateTokenRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 48
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A rules() 0 11 1
A messages() 0 9 1
1
<?php
2
3
namespace SquareetLabs\LaravelOpenVidu\Http\Requests;
4
5
use Illuminate\Foundation\Http\FormRequest;
6
use Illuminate\Validation\Rule;
7
use SquareetLabs\LaravelOpenVidu\Enums\MediaMode;
8
use SquareetLabs\LaravelOpenVidu\Enums\OpenViduRole;
9
use SquareetLabs\LaravelOpenVidu\Enums\OutputMode;
10
use SquareetLabs\LaravelOpenVidu\Enums\RecordingLayout;
11
use SquareetLabs\LaravelOpenVidu\Enums\RecordingMode;
12
13
/**
14
 * Class GenerateTokenRequest
15
 * @package SquareetLabs\LaravelOpenVidu\Http\Requests
16
 */
17
class GenerateTokenRequest extends /** @scrutinizer ignore-call */
18
    FormRequest
19
{
20
21
22
    /**
23
     * Determine if the user is authorized to make this request.
24
     *
25
     * @return bool
26
     */
27
    public function authorize()
28
    {
29
        return true;
30
    }
31
32
    /**
33
     * Get the validation rules that apply to the request.
34
     *
35
     * @return array
36
     */
37
    public function rules()
38
    {
39
        return [
40
            'session.mediaMode' => ['string', Rule::in([MediaMode::ROUTED, MediaMode::RELAYED])],
41
            'session.recordingMode' => ['string', Rule::in([RecordingMode::MANUAL, RecordingMode::ALWAYS])],
42
            'session.defaultOutputMode' => ['string', Rule::in([OutputMode::COMPOSED, OutputMode::COMPOSED_QUICK_START, OutputMode::INDIVIDUAL])],
43
            'session.defaultRecordingLayout' => ['string', Rule::in([RecordingLayout::CUSTOM, RecordingLayout::BEST_FIT])],
44
            'session.defaultCustomLayout' => 'string',
45
            'session.customSessionId' => 'string',
46
            'tokenOptions.data' => 'nullable|string',
47
            'tokenOptions.role' => ['string', Rule::in([OpenViduRole::MODERATOR, OpenViduRole::PUBLISHER, OpenViduRole::SUBSCRIBER])],
48
        ];
49
    }
50
51
    /**
52
     * Get the error messages for the defined validation rules.
53
     *
54
     * @return array
55
     */
56
    public function messages()
57
    {
58
        return [
59
            'session.mediaMode.in' => /** @scrutinizer ignore-call */ __('validation.session.mediaMode_in'),
60
            'session.recordingMode.in' => /** @scrutinizer ignore-call */ __('validation.session.recordingMode_in'),
61
            'session.defaultOutputMode.in' => /** @scrutinizer ignore-call */ __('validation.session.defaultOutputMode_in'),
62
            'session.defaultRecordingLayout.in' => /** @scrutinizer ignore-call */ __('validation.session.defaultRecordingLayout_in'),
63
            'session.defaultCustomLayout.in' => /** @scrutinizer ignore-call */ __('validation.session.defaultCustomLayout_in'),
64
            'tokenOptions.role.in' => /** @scrutinizer ignore-call */ __('validation.session.defaultCustomLayout_in'),
65
        ];
66
    }
67
}
68