Passed
Push — master ( 3f90a4...ba6473 )
by Roman
07:34 queued 05:03
created

ValidationServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KielD01\PhoneValidation\Providers;
6
7
use Illuminate\Support\Facades\Log;
8
use Illuminate\Support\Facades\Validator;
9
use Illuminate\Support\ServiceProvider;
10
use KielD01\PhoneValidation\Enum\PhoneRegex;
11
use KielD01\PhoneValidation\Enum\PhoneRules;
12
13
class ValidationServiceProvider extends ServiceProvider
14
{
15
	public function register()
16
	{
17
		Log::info(sprintf('%s has been registered', __CLASS__));
18
	}
19
20
	public function boot()
21
	{
22
		Validator::extend(
23
			PhoneRules::WORLD,
24
			static function ($attribute, $value) {
25
				return preg_match(PhoneRegex::WORLD, $value);
26
			}
27
		);
28
29
		Validator::extend(
30
			PhoneRules::CIS,
31
			static function ($attribute, $value) {
32
				return preg_match(PhoneRegex::CIS, $value);
33
			}
34
		);
35
	}
36
}
37