Completed
Push — master ( b84639...0da43a )
by Mahmoud
03:35
created

UpdateUserRequest::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A UpdateUserRequest::authorize() 0 4 1
1
<?php
2
3
namespace App\Containers\User\UI\API\Requests;
4
5
use App\Containers\Authentication\Tasks\GetAuthenticatedUserTask;
6
use App\Containers\User\Models\User;
7
use App\Port\Request\Abstracts\Request;
8
use Illuminate\Contracts\Auth\Access\Gate;
9
10
/**
11
 * Class UpdateUserRequest.
12
 *
13
 * @author Mahmoud Zalt <[email protected]>
14
 */
15
class UpdateUserRequest extends Request
16
{
17
18
    /**
19
     * Get the validation rules that apply to the request.
20
     *
21
     * @return array
22
     */
23
    public function rules()
24
    {
25
        return [
26
            'password' => 'min:6|max:30',
27
            'name'     => 'min:2|max:50',
28
            'email'    => 'email',
29
        ];
30
    }
31
32
    /**
33
     * Determine if the user is authorized to make this request.
34
     *
35
     * @param \Illuminate\Contracts\Auth\Access\Gate $gate
36
     *
37
     * @return bool
38
     */
39
    public function authorize(Gate $gate, GetAuthenticatedUserTask $getAuthenticatedUserTask)
40
    {
41
        return $gate->getPolicyFor(User::class)->update($this->user(), $getAuthenticatedUserTask->run()->id);
0 ignored issues
show
Bug introduced by
The method getPolicyFor() does not exist on Illuminate\Contracts\Auth\Access\Gate. Did you maybe mean policy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
42
    }
43
}
44