Passed
Push — dev ( 45bf8d...5b8f46 )
by Janko
10:07
created

AnomalyLayerRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 22
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A render() 0 19 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Map\VisualPanel\Layer\Render;
6
7
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Lib\Map\VisualPanel\Layer\Data\AnomalyData;
9
use Stu\Lib\Map\VisualPanel\Layer\Data\CellDataInterface;
10
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerEnum;
11
use Stu\Lib\Map\VisualPanel\PanelAttributesInterface;
12
13
final class AnomalyLayerRenderer implements LayerRendererInterface
14
{
15
    /** @param AnomalyData $data */
16 2
    #[Override]
17
    public function render(CellDataInterface $data, PanelAttributesInterface $panel): string
18
    {
19 2
        if ($data->getAnomalyTypes() === null) {
0 ignored issues
show
Bug introduced by
The method getAnomalyTypes() does not exist on Stu\Lib\Map\VisualPanel\...\Data\CellDataInterface. It seems like you code against a sub-type of Stu\Lib\Map\VisualPanel\...\Data\CellDataInterface such as Stu\Lib\Map\VisualPanel\Layer\Data\AnomalyData. ( Ignorable by Annotation )

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

19
        if ($data->/** @scrutinizer ignore-call */ getAnomalyTypes() === null) {
Loading history...
20 1
            return '';
21
        }
22
23 1
        $zIndex = PanelLayerEnum::ANOMALIES->value;
24
25 1
        return implode(
26 1
            "\n",
27 1
            array_map(function (string $anomalyType) use (&$zIndex, $panel): string {
28 1
                return sprintf(
29 1
                    '<img src="/assets/map/anomalies/%s.png" class="visualPanelLayer" style="z-index: %d; %s opacity: 1;" />',
30 1
                    $anomalyType,
31 1
                    $zIndex++,
32 1
                    $panel->getHeightAndWidth()
33 1
                );
34 1
            }, $data->getAnomalyTypes())
35 1
        );
36
    }
37
}
38