FormStepRequest::authorize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace MedianetDev\BackpackForm\Http\Requests;
4
5
use App\Models\DocumentVersionTranslation;
0 ignored issues
show
Bug introduced by
The type App\Models\DocumentVersionTranslation was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Validation\Rule;
8
9
class FormStepRequest extends FormRequest
10
{
11
    public function authorize()
12
    {
13
        return backpack_auth()->check();
14
    }
15
16
    public function rules()
17
    {
18
        $locale = locale();
0 ignored issues
show
Bug introduced by
The function locale was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $locale = /** @scrutinizer ignore-call */ locale();
Loading history...
19
        $id = request()->id;
20
        return [
21
            $locale . '.title'       => 'required|min:3|max:255',
22
            $locale . '.description' => 'nullable',
23
            'is_active'              => 'required|boolean',
24
            'order' => [
25
                'required',
26
                'integer',
27
                Rule::unique('med_form_steps', 'order')->where(function ($query) {
28
                    return $query->where('form_id', request()->form_id);
29
                })->ignore($id),
30
            ],
31
32
            'form_id'      => 'required|integer|exists:med_forms,id',
33
        ];
34
35
    }
36
37
    public function attributes()
38
    {
39
        $language = default_language();
0 ignored issues
show
Bug introduced by
The function default_language was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        $language = /** @scrutinizer ignore-call */ default_language();
Loading history...
40
        $attributes[$language . '.title'] = __('medianet-dev.backpack-form::formbuilder.labels.title') . ' ' . trans('medianet-dev.backpack-form::formbuilder.common.in_langue') . ' ' . trans('medianet-dev.backpack-form::formbuilder.languages.' . $language);
0 ignored issues
show
Bug introduced by
Are you sure trans('medianet-dev.back...lder.common.in_langue') of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $attributes[$language . '.title'] = __('medianet-dev.backpack-form::formbuilder.labels.title') . ' ' . /** @scrutinizer ignore-type */ trans('medianet-dev.backpack-form::formbuilder.common.in_langue') . ' ' . trans('medianet-dev.backpack-form::formbuilder.languages.' . $language);
Loading history...
Bug introduced by
Are you sure trans('medianet-dev.back...anguages.' . $language) of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $attributes[$language . '.title'] = __('medianet-dev.backpack-form::formbuilder.labels.title') . ' ' . trans('medianet-dev.backpack-form::formbuilder.common.in_langue') . ' ' . /** @scrutinizer ignore-type */ trans('medianet-dev.backpack-form::formbuilder.languages.' . $language);
Loading history...
Bug introduced by
Are you sure __('medianet-dev.backpac...mbuilder.labels.title') of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

40
        $attributes[$language . '.title'] = /** @scrutinizer ignore-type */ __('medianet-dev.backpack-form::formbuilder.labels.title') . ' ' . trans('medianet-dev.backpack-form::formbuilder.common.in_langue') . ' ' . trans('medianet-dev.backpack-form::formbuilder.languages.' . $language);
Loading history...
Comprehensibility Best Practice introduced by
$attributes was never initialized. Although not strictly required by PHP, it is generally a good practice to add $attributes = array(); before regardless.
Loading history...
41
        $attributes['order'] = __('medianet-dev.backpack-form::formbuilder.labels.order');
42
        return $attributes;
43
    }
44
    public function messages()
45
    {
46
        return [];
47
    }
48
}
49