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

LazyAggregate::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 2
c 1
b 0
f 1
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\Aggregate;
7
use Sirius\Orm\Relation\Relation;
8
9
class LazyAggregate implements LazyLoader
10
{
11
    /**
12
     * @var EntityInterface
13
     */
14
    protected $entity;
15
    /**
16
     * @var Tracker
17
     */
18
    protected $tracker;
19
    /**
20
     * @var Aggregate
21
     */
22
    protected $aggregate;
23
24
    public function __construct(EntityInterface $entity, Tracker $tracker, Aggregate $aggregate)
25
    {
26
        $this->entity   = $entity;
27
        $this->tracker  = $tracker;
28
        $this->aggregate = $aggregate;
29
    }
30
31
    public function load()
32
    {
33
        $results = $this->tracker->getAggregateResults($this->aggregate);
34
        $this->aggregate->attachAggregateToEntity($this->entity, $results);
35
    }
36
}
37