Passed
Push — master ( 31bb1c...730203 )
by Ryosuke
01:52
created

boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 9.552
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mpyw\EloquentHasByNonDependentSubquery;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Support\ServiceProvider;
7
8
class EloquentHasByNonDependentSubqueryServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register Eloquent\Builder::hasByNonDependentSubquery() macros.
12
     */
13 23
    public function boot(): void
14
    {
15
        Builder::macro('hasByNonDependentSubquery', function (...$args) {
0 ignored issues
show
Bug introduced by
The method macro() does not seem to exist on object<Illuminate\Database\Eloquent\Builder>.

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...
16
            /** @var \Illuminate\Database\Eloquent\Builder $query */
17 20
            $query = $this;
18 20
            return (new HasByNonDependentSubqueryMacro($query))->has(...$args);
19 23
        });
20
        Builder::macro('orHasByNonDependentSubquery', function (...$args) {
0 ignored issues
show
Bug introduced by
The method macro() does not seem to exist on object<Illuminate\Database\Eloquent\Builder>.

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...
21
            /** @var \Illuminate\Database\Eloquent\Builder $query */
22 1
            $query = $this;
23 1
            return (new HasByNonDependentSubqueryMacro($query))->orHas(...$args);
24 23
        });
25
        Builder::macro('doesntHaveByNonDependentSubquery', function (...$args) {
0 ignored issues
show
Bug introduced by
The method macro() does not seem to exist on object<Illuminate\Database\Eloquent\Builder>.

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...
26
            /** @var \Illuminate\Database\Eloquent\Builder $query */
27 1
            $query = $this;
28 1
            return (new HasByNonDependentSubqueryMacro($query))->doesntHave(...$args);
29 23
        });
30
        Builder::macro('orDoesntHaveByNonDependentSubquery', function (...$args) {
0 ignored issues
show
Bug introduced by
The method macro() does not seem to exist on object<Illuminate\Database\Eloquent\Builder>.

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...
31
            /** @var \Illuminate\Database\Eloquent\Builder $query */
32 1
            $query = $this;
33 1
            return (new HasByNonDependentSubqueryMacro($query))->orDoesntHave(...$args);
34 23
        });
35
    }
36
}
37