Passed
Pull Request — main (#25)
by Seth
03:52 queued 01:14
created

ReleaseNoteUpdateRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 27
c 1
b 0
f 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A getCountry() 0 3 1
A rules() 0 14 1
1
<?php
2
3
namespace SaasReady\Http\Requests\ReleaseNote;
4
5
use Illuminate\Validation\Rule;
6
use SaasReady\Http\Requests\BaseFormRequest;
7
use SaasReady\Models\Country;
0 ignored issues
show
Bug introduced by
The type SaasReady\Models\Country 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...
8
9
class ReleaseNoteUpdateRequest extends BaseFormRequest
10
{
11
    public function authorize(): bool
12
    {
13
        return true;
14
    }
15
16
    public function rules(): array
17
    {
18
        return [
19
            'code' => [
20
                'nullable',
21
                'string',
22
                'min:2',
23
                'max:2',
24
                Rule::unique((new Country())->getTable(), 'code')
25
                    ->whereNot('code', $this->getCountry()->code->value),
26
            ],
27
            'name' => 'nullable|string',
28
            'continent' => 'nullable|string',
29
            'dial_code' => 'nullable|string|starts_with:+',
30
        ];
31
    }
32
33
    public function getCountry(): Country
34
    {
35
        return $this->route('country');
36
    }
37
}
38