Passed
Push — master ( ea0818...92b4a6 )
by Adrian
01:28
created

LazyRelation   A

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);
0 ignored issues
show
Bug introduced by
It seems like $results can also be of type null; however, parameter $queryResult of Sirius\Orm\Relation\Rela...attachMatchesToEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        $this->relation->attachMatchesToEntity($this->entity, /** @scrutinizer ignore-type */ $results);
Loading history...
34
    }
35
}
36