UpdateRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 8 2
A rules() 0 6 1
1
<?php
2
3
namespace Faithgen\Discussions\Http\Requests;
4
5
use Faithgen\Discussions\Services\DiscussionService;
6
use Faithgen\Discussions\Traits\SavesDiscussion;
7
use Illuminate\Foundation\Http\FormRequest;
8
9
class UpdateRequest extends FormRequest
10
{
11
    use SavesDiscussion;
12
13
    /**
14
     * Determine if the user is authorized to make this request.
15
     *
16
     * @param  DiscussionService  $discussionService
17
     *
18
     * @return bool
19
     */
20
    public function authorize(DiscussionService $discussionService)
21
    {
22
        if (! $discussionService->getDiscussion()) {
23
            return false;
24
        }
25
26
        return $this->user()->can('update', $discussionService->getDiscussion());
27
    }
28
29
    /**
30
     * Get the validation rules that apply to the request.
31
     *
32
     * @return array
33
     */
34
    public function rules()
35
    {
36
        return array_merge([
37
            'title' => 'required|string',
38
        ], $this->getSaveRules());
39
    }
40
}
41