Passed
Pull Request — master (#13)
by Zing
06:49 queued 02:36
created

NestedRelation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveNestedRelation() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Zing\QueryBuilder\Concerns;
6
7
use Illuminate\Support\Collection;
8
use Illuminate\Support\Str;
9
10
trait NestedRelation
11
{
12 3
    protected function resolveNestedRelation($property)
13
    {
14 3
        return collect(explode('.', $property))
15 3
            ->pipe(
16
                function (Collection $parts) {
17
                    return [
18 3
                        $parts->except(count($parts) - 1)->map([Str::class, 'camel'])->implode('.'),
19 3
                        $parts->last(),
20
                    ];
21 3
                }
22
            );
23
    }
24
}
25