Passed
Pull Request — master (#200)
by
unknown
10:24
created

CreateCountryRequest::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
c 1
b 0
f 1
dl 0
loc 8
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Create Country Request.
4
 *
5
 * @package App\Http\Requests\Country
6
 *
7
 * @author    Nick Menke <[email protected]>
8
 * @copyright 2018-2020 Nick Menke
9
 *
10
 * @link https://github.com/nlmenke/vertebrae
11
 */
12
13
declare(strict_types=1);
14
15
namespace App\Http\Requests\Country;
16
17
use App\Http\Requests\AbstractFormRequest;
18
19
/**
20
 * The Create Country form request class.
21
 *
22
 * This class handles form validation for creation of a new country. It also
23
 * permits (or denies) a user access to create a country.
24
 *
25
 * @since x.x.x introduced
26
 */
27
class CreateCountryRequest extends AbstractFormRequest
28
{
29
    /**
30
     * Does the current user have access?
31
     *
32
     * @return bool
33
     */
34 2
    public function authorize(): bool
35
    {
36 2
        return true;
37
    }
38
39
    /**
40
     * The authorization rules.
41
     *
42
     * @return array
43
     */
44
    public function rules(): array
45
    {
46
        return [
47
            'currency_id' => 'integer|nullable',
48
            'iso_alpha_2' => 'required|string|size:2|unique:countries',
49
            'iso_alpha_3' => 'required|string|size:3|unique:countries',
50
            'iso_numeric' => 'required|string|size:3|unique:countries',
51
            'name' => 'required|string',
52
        ];
53
    }
54
}
55