| Conditions | 2 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2.024 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 16 | 4 | public function boot() |
|
| 17 | { |
||
| 18 | // Fixes incompatibility with MySQL < 5.7.7 |
||
| 19 | 4 | Schema::defaultStringLength(191); |
|
| 20 | |||
| 21 | // Create {{ $view_name }} provider in blade templates |
||
| 22 | view()->composer('*', function($view) { |
||
|
|
|||
| 23 | 1 | $view_name = str_replace('.', '-', $view->getName()); |
|
| 24 | 1 | view()->share('view_name', $view_name); |
|
| 25 | 4 | }); |
|
| 26 | |||
| 27 | 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 | 4 | }); |
|
| 30 | |||
| 31 | 4 | Validator::replacer('phone', function($message, $attribute, $rule, $parameters) { |
|
| 32 | return str_replace(':attribute',$attribute, ':attribute is invalid phone number'); |
||
| 33 | 4 | }); |
|
| 34 | 4 | } |
|
| 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: