Completed
Push — master ( 8927df...f70445 )
by Abdelrahman
02:05
created

UserSettingsUpdateRequest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 43
rs 10
c 1
b 0
f 0
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 4 1
A process() 0 8 2
A rules() 0 9 1
1
<?php
2
3
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Fort Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Fort Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Fort\Http\Requests\Frontend;
17
18
use Rinvex\Support\Http\Requests\FormRequest;
19
20
class UserSettingsUpdateRequest extends FormRequest
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
     * Process given request data before validation.
34
     *
35
     * @param array $data
36
     *
37
     * @return array
38
     */
39
    public function process($data)
40
    {
41
        if (empty($data['password'])) {
42
            unset($data['password'], $data['password_confirmation']);
43
        }
44
45
        return array_filter(array_map('trim', $data));
46
    }
47
48
    /**
49
     * Get the validation rules that apply to the request.
50
     *
51
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
52
     */
53
    public function rules()
54
    {
55
        return [
56
            'email'    => 'required|email|max:255|unique:'.config('rinvex.fort.tables.users').',email,'.$this->get('id'),
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
57
            'username' => 'required|max:255|unique:'.config('rinvex.fort.tables.users').',username,'.$this->get('id'),
58
            'phone'    => 'required|numeric|unique:'.config('rinvex.fort.tables.users').',phone,'.$this->get('id'),
59
            'password' => 'sometimes|required|min:6|confirmed',
60
        ];
61
    }
62
}
63