LazyRelation::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Orm\Entity;
5
6
use Sirius\Orm\Relation\Relation;
7
8
class LazyRelation implements LazyLoader
9
{
10
    /**
11
     * @var EntityInterface
12
     */
13
    protected $entity;
14
    /**
15
     * @var Tracker
16
     */
17
    protected $tracker;
18
    /**
19
     * @var Relation
20
     */
21
    protected $relation;
22
23
    public function __construct(EntityInterface $entity, Tracker $tracker, Relation $relation)
24
    {
25
        $this->entity   = $entity;
26
        $this->tracker  = $tracker;
27
        $this->relation = $relation;
28
    }
29
30
    public function load()
31
    {
32
        $results = $this->tracker->getResultsForRelation($this->relation->getOption('name'));
33
        $this->relation->attachMatchesToEntity($this->entity, $results);
34
    }
35
}
36