LazyRelation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
c 0
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A load() 0 4 1
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