Completed
Branch develop-3.0 (ae28cb)
by Mohamed
08:28
created

UserSetting::actions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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
/**
15
 * UserSetting is a class to defines fields & rules for add/edit user settings form.
16
 *
17
 * @author Mohamed Alsharaf <[email protected]>
18
 */
19
class UserSetting extends User
20
{
21
    public function setup(array $params)
22
    {
23
        parent::setup($params);
24
25
        $this->setModel($this->getLoggedUser());
0 ignored issues
show
Documentation introduced by
$this->getLoggedUser() is of type object<Tinyissue\Contracts\Model\UserInterface>, but the function expects a null|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...
26
    }
27
28
    /**
29
     * @return array
30
     */
31
    public function actions()
32
    {
33
        return [
34
            'submit' => 'update',
35
        ];
36
    }
37
38
    /**
39
     * @return array
40
     */
41
    protected function innerFields()
42
    {
43
        $fields = [
44
            'language' => [
45
                'type'    => 'select',
46
                'label'   => 'language',
47
                'options' => config('tinyissue.supported_lang'),
48
                'value'   => app('tinyissue.settings')->getLanguage(),
49
            ],
50
        ];
51
        $fields += $this->passwordFields();
52
53
        return $fields;
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function rules()
60
    {
61
        $rules             = parent::rules();
62
        $rules['password'] = 'confirmed';
63
        $rules['language'] = 'required';
64
65
        return $rules;
66
    }
67
}
68