EloquentHasByNonDependentSubqueryServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 26
ccs 16
cts 16
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 21 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 25
    public function boot(): void
14
    {
15 25
        Builder::macro('hasByNonDependentSubquery', function ($relationMethod, ?callable ...$constraints): Builder {
0 ignored issues
show
Bug introduced by
The method macro() does not exist on Illuminate\Database\Eloquent\Builder. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
        Builder::/** @scrutinizer ignore-call */ 
16
                 macro('hasByNonDependentSubquery', function ($relationMethod, ?callable ...$constraints): 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 21
            $query = $this;
18 21
            return (new HasByNonDependentSubqueryMacro($query))->has($relationMethod, ...$constraints);
19 25
        });
20 25
        Builder::macro('orHasByNonDependentSubquery', function ($relationMethod, ?callable ...$constraints): Builder {
21
            /** @var \Illuminate\Database\Eloquent\Builder $query */
22 1
            $query = $this;
23 1
            return (new HasByNonDependentSubqueryMacro($query))->orHas($relationMethod, ...$constraints);
24 25
        });
25 25
        Builder::macro('doesntHaveByNonDependentSubquery', function ($relationMethod, ?callable ...$constraints): Builder {
26
            /** @var \Illuminate\Database\Eloquent\Builder $query */
27 1
            $query = $this;
28 1
            return (new HasByNonDependentSubqueryMacro($query))->doesntHave($relationMethod, ...$constraints);
29 25
        });
30 25
        Builder::macro('orDoesntHaveByNonDependentSubquery', function ($relationMethod, ?callable ...$constraints): Builder {
31
            /** @var \Illuminate\Database\Eloquent\Builder $query */
32 1
            $query = $this;
33 1
            return (new HasByNonDependentSubqueryMacro($query))->orDoesntHave($relationMethod, ...$constraints);
34 25
        });
35
    }
36
}
37