AreaChart::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace CMEN\GoogleChartsBundle\GoogleCharts\Charts;
4
5
use CMEN\GoogleChartsBundle\GoogleCharts\Chart;
6
use CMEN\GoogleChartsBundle\GoogleCharts\EventType;
7
use CMEN\GoogleChartsBundle\GoogleCharts\Options\AreaChart\AreaChartOptions;
8
use CMEN\GoogleChartsBundle\GoogleCharts\Options\ChartOptionsInterface;
9
10
/**
11
 * @author Christophe Meneses
12
 */
13
class AreaChart extends Chart
14
{
15
    /**
16
     * @var AreaChartOptions
17
     */
18
    protected ChartOptionsInterface $options;
19
20
    public function __construct()
21
    {
22
        parent::__construct();
23
24
        $this->options = new AreaChartOptions();
25
    }
26
27
    public function getType(): string
28
    {
29
        return 'AreaChart';
30
    }
31
32
    public function getPackage(): string
33
    {
34
        return 'corechart';
35
    }
36
37
    public function getAvailableEventTypes(): array
38
    {
39
        return [
40
            EventType::ANIMATION_FINISH,
41
            EventType::CLICK,
42
            EventType::ERROR,
43
            EventType::ON_MOUSE_OUT,
44
            EventType::ON_MOUSE_OVER,
45
            EventType::READY,
46
            EventType::SELECT,
47
        ];
48
    }
49
50
    public function getOptions(): AreaChartOptions
51
    {
52
        return $this->options;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->options returns the type CMEN\GoogleChartsBundle\...s\ChartOptionsInterface which includes types incompatible with the type-hinted return CMEN\GoogleChartsBundle\...aChart\AreaChartOptions.
Loading history...
53
    }
54
55
    /**
56
     * @param AreaChartOptions $options
57
     */
58
    public function setOptions(ChartOptionsInterface $options): AreaChart
59
    {
60
        $this->options = $options;
0 ignored issues
show
Documentation Bug introduced by
$options is of type CMEN\GoogleChartsBundle\...s\ChartOptionsInterface, but the property $options was declared to be of type CMEN\GoogleChartsBundle\...aChart\AreaChartOptions. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
61
62
        return $this;
63
    }
64
}
65