LazyAggregate   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

2 Methods

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