CountryServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 12 1
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
        }, trans('validation.invalid_country'));
21
22
        // Add currency validation rule
23
        Validator::extend('currency', function ($attribute, $value) {
24
            return array_key_exists($value, currencies());
25
        }, trans('validation.invalid_currency'));
26
    }
27
}
28