Passed
Pull Request — master (#1696)
by Nico
49:43 queued 22:34
created

BuildingManagementProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 22
ccs 0
cts 7
cp 0
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplateVariables() 0 8 1
A __construct() 0 6 1
1
<?php
2
3
namespace Stu\Module\Colony\Lib\Gui\Component;
4
5
use Stu\Lib\Colony\PlanetFieldHostInterface;
6
use Stu\Module\Control\GameControllerInterface;
7
use Stu\Orm\Repository\CommodityRepositoryInterface;
8
use Stu\Orm\Repository\PlanetFieldRepositoryInterface;
9
10
final class BuildingManagementProvider implements GuiComponentProviderInterface
11
{
12
    private PlanetFieldRepositoryInterface $planetFieldRepository;
13
14
    private CommodityRepositoryInterface $commodityRepository;
15
16
    public function __construct(
17
        PlanetFieldRepositoryInterface $planetFieldRepository,
18
        CommodityRepositoryInterface $commodityRepository
19
    ) {
20
        $this->planetFieldRepository = $planetFieldRepository;
21
        $this->commodityRepository = $commodityRepository;
22
    }
23
24
    public function setTemplateVariables(
25
        PlanetFieldHostInterface $host,
26
        GameControllerInterface $game
27
    ): void {
28
        $list = $this->planetFieldRepository->getByColonyWithBuilding($host);
29
30
        $game->setTemplateVar('PLANET_FIELD_LIST', $list);
31
        $game->setTemplateVar('USEABLE_COMMODITY_LIST', $this->commodityRepository->getByBuildingsOnColony($host));
32
    }
33
}
34