Completed
Push — master ( 3581a6...fa6af9 )
by Jodie
04:06
created

RelationLoader::getRelationshipKeys()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
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
    public function load(ResourceInterface $resource, array $relationshipKeys)
16
    {
17
        // Eager load relationships on collections
18
        $obj = $resource->getData();
19
        if ($obj instanceof Collection) {
20
            $obj->load($relationshipKeys);
21
        }
22
    }
23
}
24