Passed
Pull Request — master (#38)
by Christophe
05:14
created

Map::getPackage()   A

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
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\Map\MapOptions;
8
9
/**
10
 * @author Christophe Meneses
11
 */
12
class Map extends Chart
13
{
14
    /**
15
     * @var MapOptions
16
     */
17
    protected $options;
18
19 1
    public function __construct()
20
    {
21 1
        parent::__construct();
22
23 1
        $this->options = new MapOptions();
24 1
    }
25
26
    public function getType()
27
    {
28
        return 'Map';
29
    }
30
31
    public function getPackage()
32
    {
33
        return 'map';
34
    }
35
36 1
    public function getAvailableEventTypes()
37
    {
38
        return [
39 1
            EventType::ERROR,
40 1
            EventType::SELECT,
41
        ];
42
    }
43
44
    /**
45
     * @return MapOptions
46
     */
47
    public function getOptions()
48
    {
49
        return $this->options;
50
    }
51
52
    /**
53
     * @param MapOptions $options
54
     *
55
     * @return Map
56
     */
57
    public function setOptions($options)
58
    {
59
        $this->options = $options;
60
61
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type CMEN\GoogleChartsBundle\GoogleCharts\Charts\Map which is incompatible with the return type mandated by CMEN\GoogleChartsBundle\...rts\Chart::setOptions() of CMEN\GoogleChartsBundle\...s\ChartOptionsInterface.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
62
    }
63
}
64