IsConcatenable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A appendToDeepRelationship() 0 21 4
1
<?php
2
3
namespace Staudenmeir\EloquentHasManyDeep\Eloquent\Relations\Traits;
4
5
use Illuminate\Database\Eloquent\Relations\Pivot;
6
7
trait IsConcatenable
8
{
9
    /**
10
     * Append the relation's through parents, foreign and local keys to a deep relationship.
11
     *
12
     * @param \Illuminate\Database\Eloquent\Model[] $through
13
     * @param array $foreignKeys
14
     * @param array $localKeys
15
     * @param int $position
16
     * @return array
17
     */
18 6
    public function appendToDeepRelationship(array $through, array $foreignKeys, array $localKeys, int $position): array
0 ignored issues
show
Unused Code introduced by
The parameter $position is not used and could be removed. ( Ignorable by Annotation )

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

18
    public function appendToDeepRelationship(array $through, array $foreignKeys, array $localKeys, /** @scrutinizer ignore-unused */ int $position): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
    {
20 6
        foreach ($this->throughParents as $throughParent) {
21 6
            $segments = explode(' as ', $throughParent->getTable());
22
23 6
            $class = get_class($throughParent);
24
25 6
            if (isset($segments[1])) {
26 2
                $class .= ' as '.$segments[1];
27 6
            } elseif ($throughParent instanceof Pivot) {
28 2
                $class = $throughParent->getTable();
29
            }
30
31 6
            $through[] = $class;
32
        }
33
34 6
        $foreignKeys = array_merge($foreignKeys, $this->foreignKeys);
35
36 6
        $localKeys = array_merge($localKeys, $this->localKeys);
37
38 6
        return [$through, $foreignKeys, $localKeys];
39
    }
40
}
41