Passed
Push — master ( 6b02b9...a180a6 )
by Nico
26:39 queued 18:43
created

MapItem::getMapGraphicPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 11
ccs 0
cts 8
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Module\Admin\View\Map\EditSection;
6
7
use Stu\Component\Map\EncodedMapInterface;
8
use Stu\Orm\Entity\MapInterface;
9
10
class MapItem
11
{
12
    private EncodedMapInterface $encodedMap;
13
14
    private MapInterface $map;
15
16
    public function __construct(
17
        EncodedMapInterface $encodedMap,
18
        MapInterface $map
19
    ) {
20
        $this->encodedMap = $encodedMap;
21
        $this->map = $map;
22
    }
23
24
    public function getMap(): MapInterface
25
    {
26
        return $this->map;
27
    }
28
29
    public function getMapGraphicPath(): string
30
    {
31
        $layer = $this->map->getLayer();
32
33
        if ($layer->isEncoded()) {
34
            return $this->encodedMap->getEncodedMapPath(
35
                $this->map->getFieldId(),
36
                $layer
37
            );
38
        }
39
        return sprintf('%d/%d.png', $layer->getId(), $this->map->getFieldId());
40
    }
41
}
42