UserSetting::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Form;
13
14
use Illuminate\Contracts\Auth\Guard;
15
16
/**
17
 * UserSetting is a class to defines fields & rules for add/edit user settings form.
18
 *
19
 * @author Mohamed Alsharaf <[email protected]>
20
 */
21
class UserSetting extends User
22
{
23
    /**
24
     * @param Guard $model
25
     */
26 4
    public function __construct(Guard $model)
27
    {
28 4
        $this->editingModel($model->user());
0 ignored issues
show
Documentation introduced by
$model->user() is of type object<Illuminate\Contra...h\Authenticatable>|null, but the function expects a object<Illuminate\Database\Eloquent\Model>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29 4
    }
30
31
    /**
32
     * @return array
33
     */
34 4
    public function actions()
35
    {
36
        return [
37 4
            'submit' => 'update',
38
        ];
39
    }
40
41
    /**
42
     * @return array
43
     */
44 4
    protected function innerFields()
45
    {
46
        $fields = [
47
            'language' => [
48 4
                'type'    => 'select',
49 4
                'label'   => 'language',
50 4
                'options' => $this->getModel()->getLanguages(),
51 4
                'value'   => app('tinyissue.settings')->getLanguage(),
52
            ],
53
        ];
54 4
        $fields += $this->passwordFields();
55
56 4
        return $fields;
57
    }
58
59
    /**
60
     * @return array
61
     */
62 4
    public function rules()
63
    {
64 4
        $rules             = parent::rules();
65 4
        $rules['password'] = 'confirmed';
66 4
        $rules['language'] = 'required';
67
68 4
        return $rules;
69
    }
70
}
71