SupportServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Support\Providers;
6
7
use Illuminate\Support\Collection;
8
use Illuminate\Support\ServiceProvider;
9
use Illuminate\Support\Facades\Validator;
10
11
class SupportServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function boot()
17
    {
18
        // Add strip_tags validation rule
19
        Validator::extend('strip_tags', function ($attribute, $value) {
20
            return strip_tags($value) === $value;
21
        }, trans('validation.invalid_strip_tags'));
22
23
        // Add time offset validation rule
24
        Validator::extend('timeoffset', function ($attribute, $value) {
25
            return array_key_exists($value, timeoffsets());
26
        }, trans('validation.invalid_timeoffset'));
27
28
        Collection::macro('similar', function (Collection $newCollection) {
29
            return $newCollection->diff($this)->isEmpty() && $this->diff($newCollection)->isEmpty();
0 ignored issues
show
Bug introduced by
The method diff() does not seem to exist on object<Rinvex\Support\Pr...SupportServiceProvider>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        });
31
    }
32
}
33