Test Failed
Pull Request — master (#94)
by Zing
06:54 queued 02:38
created

NestedRelation   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 10
wmc 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 4
    protected function resolveNestedRelation($property)
13
    {
14 4
        return collect(explode('.', $property))
15 4
            ->pipe(
16 4
                function (Collection $parts) {
17
                    return [
18 4
                        $parts->except(count($parts) - 1)
19 4
                            ->map(function (string $value): string {
20 4
                                return Str::class->camel($value);
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_OBJECT_OPERATOR, expecting ';' on line 20 at column 49
Loading history...
21
                            })->implode('.'),
22 4
                        $parts->last(),
23
                    ];
24
                }
25
            );
26
    }
27
}
28