RelationLoader::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
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