GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ChartRenderer::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 19
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusReportPlugin\Renderer;
6
7
use Odiseo\SyliusReportPlugin\DataFetcher\Data;
8
use Odiseo\SyliusReportPlugin\Form\Type\Renderer\ChartConfigurationType;
9
use Odiseo\SyliusReportPlugin\Model\ReportInterface;
10
use Twig\Environment;
11
12
/**
13
 * @author Mateusz Zalewski <[email protected]>
14
 * @author Łukasz Chruściel <[email protected]>
15
 * @author Diego D'amico <[email protected]>
16
 * @author Rimas Kudelis <[email protected]>
17
 */
18
class ChartRenderer implements RendererInterface
19
{
20
    const BAR_CHART = 'bar';
21
    const LINE_CHART = 'line';
22
    const RADAR_CHART = 'radar';
23
    const POLAR_CHART = 'polar';
24
    const PIE_CHART = 'pie';
25
    const DOUGHNUT_CHART = 'doughnut';
26
27
    private Environment $templating;
28
29
    public function __construct(Environment $templating)
30
    {
31
        $this->templating = $templating;
32
    }
33
34
    public function render(ReportInterface $report, Data $data): string
35
    {
36
        if (null !== $data->getData()) {
0 ignored issues
show
introduced by
The condition null !== $data->getData() is always true.
Loading history...
37
            $rendererData = [
38
                'report' => $report,
39
                'values' => $data->getData(),
40
                'labels' => $data->getLabels(),
41
            ];
42
43
            $rendererConfiguration = $report->getRendererConfiguration();
44
45
            return $this->templating->render($rendererConfiguration['template'], [
46
                'data' => $rendererData,
47
                'configuration' => $rendererConfiguration,
48
            ]);
49
        }
50
51
        return $this->templating->render('@OdiseoSyliusReportPlugin/noDataTemplate.html.twig', [
52
            'report' => $report,
53
        ]);
54
    }
55
56
    public function getType(): string
57
    {
58
        return ChartConfigurationType::class;
59
    }
60
61
    public static function getChartTypes(): array
62
    {
63
        return [
64
            'Bar chart' => self::BAR_CHART,
65
            'Line chart' => self::LINE_CHART,
66
            'Radar chart' => self::RADAR_CHART,
67
            'Polar chart' => self::POLAR_CHART,
68
            'Pie chart' => self::PIE_CHART,
69
            'Doughnut chart' => self::DOUGHNUT_CHART,
70
        ];
71
    }
72
}
73