EloquentHasByJoinServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Mpyw\EloquentHasByJoin;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Support\ServiceProvider;
7
8
class EloquentHasByJoinServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Register Eloquent\Builder::hasByJoin() macro.
12
     */
13 15
    public function boot(): void
14
    {
15 15
        Builder::macro('hasByJoin', 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('hasByJoin', 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 15
            $query = $this;
18 15
            return (new HasByJoinMacro($query))($relationMethod, ...$constraints);
19 15
        });
20
    }
21
}
22