Passed
Push — master ( 6cf215...65a336 )
by Jonas
12:16
created

IsConcatenable   A

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