Passed
Push — master ( e815f2...b4cf01 )
by Adam
03:17
created

AppServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0233

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
ccs 5
cts 7
cp 0.7143
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1.0233
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Support\Facades\Validator;
6
use Illuminate\Support\ServiceProvider;
7
8
class AppServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        /*
18
         * Custom validation rules
19
         */
20 28
        Validator::extend('alpha_spaces', function ($attribute, $value) {
21
            // Accept only alpha and spaces.
22
            return preg_match('/^[\pL\s]+$/u', $value);
23 28
        });
24
25 28
        Validator::extend('alpha_spaces_hyphens', function ($attribute, $value) {
26
            // Accept only alpha, spaces and hyphens.
27
            return preg_match('/^[\pL\s-]+$/u', $value);
28 28
        });
29 28
    }
30
31
    /**
32
     * Register any application services.
33
     *
34
     * @return void
35
     */
36 28
    public function register()
37
    {
38
        //
39 28
    }
40
}
41