Conditions | 2 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.1165 |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
16 | 5 | public function boot() |
|
17 | { |
||
18 | // Fixes incompatibility with MySQL < 5.7.7 |
||
19 | 5 | Schema::defaultStringLength(191); |
|
20 | |||
21 | // Create {{ $view_name }} provider in blade templates |
||
22 | 5 | view()->composer('*', function($view) { |
|
|
|||
23 | $view_name = str_replace('.', '-', $view->getName()); |
||
24 | view()->share('view_name', $view_name); |
||
25 | 5 | }); |
|
26 | |||
27 | 5 | Validator::extend('phone', function($attribute, $value, $parameters, $validator) { |
|
28 | return preg_match('%^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$%i', $value) && strlen($value) >= 10; |
||
29 | 5 | }); |
|
30 | |||
31 | 5 | Validator::replacer('phone', function($message, $attribute, $rule, $parameters) { |
|
32 | return str_replace(':attribute', $attribute, ':attribute is invalid phone number'); |
||
33 | 5 | }); |
|
34 | 5 | } |
|
35 | |||
46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: