Passed
Push — master ( b1cbf5...bb9767 )
by Adam
06:50
created

AppServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
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 41
        Validator::extend('alpha_spaces', function ($attribute, $value) {
21
            // Accept only alpha and spaces.
22
            return preg_match('/^[\pL\s]+$/u', $value);
23 41
        });
24
25 41
        Validator::extend('alpha_spaces_hyphens', function ($attribute, $value) {
26
            // Accept only alpha, spaces and hyphens.
27 5
            return preg_match('/^[\pL\s-]+$/u', $value);
28 41
        });
29
30 41
        Validator::extend('alpha_spaces_hyphens_apostrophes', function ($attribute, $value) {
31
            // Accept only alpha, spaces, hyphens and apostrophes.
32 5
            return preg_match('/^[\pL\s-\']+$/u', $value);
33 41
        });
34
35 41
        Validator::extend('alpha_spaces_hyphens_apostrophes_parentheses', function ($attribute, $value) {
36
            // Accept only alpha, spaces, hyphens, apostrophes and parentheses.
37
            return preg_match('/^[\pL\s-\'()]+$/u', $value);
38 41
        });
39
40 41
        Validator::extend('alpha_spaces_hyphens_apostrophes_parentheses_slashes', function ($attribute, $value) {
41
            // Accept only alpha, spaces, hyphens, apostrophes, parentheses and slashes.
42
            return preg_match('/^[\pL\s-\'()\/]+$/u', $value);
43 41
        });
44
45 41
        Validator::extend('alpha_spaces_hyphens_apostrophes_parentheses_slashes_dots', function ($attribute, $value) {
46
            // Accept only alpha, spaces, hyphens, apostrophes, parentheses, slashes and dots.
47 5
            return preg_match('/^[\pL\s-\'()\/.]+$/u', $value);
48 41
        });
49 41
    }
50
51
    /**
52
     * Register any application services.
53
     *
54
     * @return void
55
     */
56 41
    public function register()
57
    {
58
        //
59 41
    }
60
}
61