Completed
Push — develop ( 2ed6dc...6fba8a )
by Abdelrahman
02:41
created

CountryServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 9.4285
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Country\Providers;
6
7
use Illuminate\Support\ServiceProvider;
8
use Illuminate\Support\Facades\Validator;
9
10
class CountryServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function boot()
16
    {
17
        // Add country validation rule
18
        Validator::extend('country', function ($attribute, $value) {
19
            return array_key_exists(mb_strtolower($value), countries());
20
        }, 'Country MUST be valid!');
21
    }
22
}
23