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.

Html::render()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 27
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 14
c 2
b 0
f 0
nc 8
nop 1
dl 0
loc 27
rs 9.7998
1
<?php
2
3
namespace Halfpastfour\PHPChartJS\Renderer;
4
5
use DOMDocument;
6
7
/**
8
 * Class Renderer
9
 *
10
 * @package Halfpastfour\PHPChartJS
11
 */
12
class Html extends Renderer
13
{
14
    /**
15
     * Renders the necessary HTML for the chart to function in the frontend.
16
     *
17
     * @param int|null $flags
18
     *
19
     * @return string
20
     */
21
    public function render($flags = null)
22
    {
23
        $dom = new DOMDocument();
24
25
        // Render canvas HTML element
26
        $canvas = $dom->createElement('canvas');
27
        $canvas->setAttribute('id', $this->chart->getId());
28
29
        // Add title, height and width if applicable
30
        if ($this->chart->getTitle()) {
31
            $canvas->setAttribute('title', $this->chart->getTitle());
32
        }
33
        if ($this->chart->getHeight()) {
34
            $canvas->setAttribute('height', $this->chart->getHeight());
35
        }
36
        if ($this->chart->getWidth()) {
37
            $canvas->setAttribute('width', $this->chart->getWidth());
38
        }
39
40
        $dom->appendChild($canvas);
41
42
        // Render JavaScript
43
        $scriptRenderer = new JavaScript($this->chart);
44
        $script         = $dom->createElement('script', $scriptRenderer->render($flags));
45
        $dom->appendChild($script);
46
47
        return $dom->saveHTML();
48
    }
49
}
50