MacroServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
dl 0
loc 33
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
A boot() 0 11 2
1
<?php
2
3
namespace mav3rick177\RapidPagination;
4
5
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
6
use Illuminate\Database\Eloquent\Relations\Relation;
7
use Illuminate\Database\Query\Builder as QueryBuilder;
8
use Illuminate\Support\ServiceProvider;
9
10
/**
11
 * Class MacroServiceProvider
12
 */
13
class MacroServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Register "rapid-pagination" macros.
17
     */
18 19
    public function register()
19
    {
20 19
        QueryBuilder::macro('rapid_pagination', function () {
21
            /* @var \Illuminate\Database\Query\Builder $this */
22 1
            return Paginator::create($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<mav3rick177\RapidPa...n\MacroServiceProvider>, but the function expects a object<Illuminate\Databa...Database\Query\Builder>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23 19
        });
24 19
        EloquentBuilder::macro('rapid_pagination', function () {
25
            /* @var \Illuminate\Database\Eloquent\Builder $this */
26 17
            return Paginator::create($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<mav3rick177\RapidPa...n\MacroServiceProvider>, but the function expects a object<Illuminate\Databa...Database\Query\Builder>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27 19
        });
28 19
        Relation::macro('rapid_pagination', function () {
29
            /* @var \Illuminate\Database\Eloquent\Relations\Relation $this */
30 3
            return Paginator::create($this);
0 ignored issues
show
Documentation introduced by
$this is of type this<mav3rick177\RapidPa...n\MacroServiceProvider>, but the function expects a object<Illuminate\Databa...Database\Query\Builder>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
31 19
        });
32
    }
33
34 19
    public function boot()
35
    {
36 19
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'rapid-pagination');
37 19
        $this->publishes([
38 19
            __DIR__.'/../resources/views' => $this->app->resourcePath('views/vendor/rapid-pagination'),
39 19
        ], 'rapid-pagination');
40
41 19
        if (\File::exists(__DIR__ . '\Helpers\helpers.php')) {
42
            require __DIR__ . '\Helpers\helpers.php';
43
        }
44
    }
45
}
46