BelongsToAncestorsTree   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 14
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A modifyQuery() 0 3 1
A getOperator() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\LTree\Relations;
6
7
use Illuminate\Database\Eloquent\Builder;
8
use Illuminate\Database\Eloquent\Model;
9
use Umbrellio\LTree\Interfaces\LTreeModelInterface;
10
use Umbrellio\LTree\Traits\LTreeModelTrait;
11
12
class BelongsToAncestorsTree extends AbstractBelongsToTree
13
{
14
    /**
15
     * @param Builder|LTreeModelTrait|Model $query
16
     * @param Model|LTreeModelInterface $model
17
     */
18 2
    protected function modifyQuery($query, Model $model): Builder
19
    {
20 2
        return $query->ancestorsOf($model);
0 ignored issues
show
Bug introduced by
It seems like ancestorsOf() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

20
        return $query->/** @scrutinizer ignore-call */ ancestorsOf($model);
Loading history...
Bug introduced by
The method ancestorsOf() 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

20
        return $query->/** @scrutinizer ignore-call */ ancestorsOf($model);

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
    }
22
23 2
    protected function getOperator(): string
24
    {
25 2
        return '@>';
26
    }
27
}
28