Passed
Push — master ( 9b5a70...c1cb1a )
by Christophe
09:50 queued 07:13
created

Map::setOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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\ChartOptionsInterface;
8
use CMEN\GoogleChartsBundle\GoogleCharts\Options\Map\MapOptions;
9
10
/**
11
 * @author Christophe Meneses
12
 */
13
class Map extends Chart
14
{
15
    /**
16
     * @var MapOptions
17
     */
18
    protected ChartOptionsInterface $options;
19
20 1
    public function __construct()
21
    {
22 1
        parent::__construct();
23
24 1
        $this->options = new MapOptions();
25
    }
26
27
    public function getType(): string
28
    {
29
        return 'Map';
30
    }
31
32
    public function getPackage(): string
33
    {
34
        return 'map';
35
    }
36
37 1
    public function getAvailableEventTypes(): array
38
    {
39
        return [
40 1
            EventType::ERROR,
41
            EventType::SELECT,
42
        ];
43
    }
44
45
    public function getOptions(): MapOptions
46
    {
47
        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\...\Options\Map\MapOptions.
Loading history...
48
    }
49
50
    /**
51
     * @param MapOptions $options
52
     */
53
    public function setOptions(ChartOptionsInterface $options): Map
54
    {
55
        $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\...\Options\Map\MapOptions. 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...
56
57
        return $this;
58
    }
59
}
60