RelationLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 6 2
1
<?php
2
3
namespace Rexlabs\Laravel\Smokescreen\Relations;
4
5
use Illuminate\Database\Eloquent\Collection;
6
use Rexlabs\Smokescreen\Relations\RelationLoaderInterface;
7
use Rexlabs\Smokescreen\Resource\ResourceInterface;
8
9
/**
10
 * Laravel implementation for loading relationships.
11
 * Smokescreen will call this automatically for all resources.
12
 */
13
class RelationLoader implements RelationLoaderInterface
14
{
15 1
    public function load(ResourceInterface $resource, array $relationshipKeys)
16
    {
17
        // Eager load relationships on collections
18 1
        $obj = $resource->getData();
19 1
        if ($obj instanceof Collection) {
20 1
            $obj->loadMissing($relationshipKeys);
21
        }
22
    }
23
}
24