GaugeChart::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\Options\ChartOptionsInterface;
7
use CMEN\GoogleChartsBundle\GoogleCharts\Options\GaugeChart\GaugeChartOptions;
8
9
/**
10
 * @author Christophe Meneses
11
 */
12
class GaugeChart extends Chart
13
{
14
    /**
15
     * @var GaugeChartOptions
16
     */
17
    protected ChartOptionsInterface $options;
18
19
    public function __construct()
20
    {
21
        parent::__construct();
22
23
        $this->options = new GaugeChartOptions();
24
    }
25
26
    public function getType(): string
27
    {
28
        return 'Gauge';
29
    }
30
31
    public function getPackage(): string
32
    {
33
        return 'gauge';
34
    }
35
36
    public function getAvailableEventTypes(): array
37
    {
38
        return [];
39
    }
40
41
    public function getOptions(): GaugeChartOptions
42
    {
43
        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\...Chart\GaugeChartOptions.
Loading history...
44
    }
45
46
    /**
47
     * @param GaugeChartOptions $options
48
     */
49
    public function setOptions(ChartOptionsInterface $options): GaugeChart
50
    {
51
        $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\...Chart\GaugeChartOptions. 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...
52
53
        return $this;
54
    }
55
}
56