GenericLazy   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
c 0
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A __construct() 0 3 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aura project for PHP.
5
 *
6
 * @package Aura.Marshal
7
 *
8
 * @license https://opensource.org/licenses/mit-license.php MIT
9
 *
10
 */
11
namespace Aura\Marshal\Lazy;
12
13
use Aura\Marshal\Relation\RelationInterface;
14
15
/**
16
 *
17
 * A generic Lazy object, useful in cases when special functionality is not
18
 * needed.
19
 *
20
 * @package Aura.Marshal
21
 *
22
 */
23
class GenericLazy implements LazyInterface
24
{
25
    /**
26
     *
27
     * A Relation object between native and foreign types.
28
     *
29
     * @var RelationInterface
30
     *
31
     */
32
    protected $relation;
33
34
    /**
35
     *
36
     * Constructor.
37
     *
38
     * @param RelationInterface $relation A relation between native and
39
     * foreign types.
40
     *
41
     */
42
    public function __construct(RelationInterface $relation)
43
    {
44
        $this->relation = $relation;
45
    }
46
47
    /**
48
     *
49
     * Gets a related foreign entity or collection for a native entity.
50
     *
51
     * @param object $entity The native entity.
52
     *
53
     * @return object The related foreign entity or collection.
54
     *
55
     */
56
    public function get($entity)
57
    {
58
        return $this->relation->getForEntity($entity);
59
    }
60
}
61