Completed
Push — master ( c1c95b...1aacd8 )
by Adam
13:41 queued 07:50
created

AppServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 13 1
A register() 0 2 1
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 93
        Validator::extend('alpha_spaces_hyphens_apostrophes', function ($attribute, $value) {
21
            // Accept only alpha, spaces, hyphens and apostrophes.
22 7
            return preg_match('/^[\pL\s-\']+$/u', $value);
23 93
        });
24
25 93
        Validator::extend('alpha_spaces_hyphens_apostrophes_parentheses_slashes_dots', function ($attribute, $value) {
26
            // Accept only alpha, spaces, hyphens, apostrophes, parentheses, slashes and dots.
27 7
            return preg_match('/^[\pL\s-\'()\/.]+$/u', $value);
28 93
        });
29 93
    }
30
31
    /**
32
     * Register any application services.
33
     *
34
     * @return void
35
     */
36 93
    public function register()
37
    {
38
        //
39 93
    }
40
}
41