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

AnnotationChart   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 58.81%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 51
ccs 10
cts 17
cp 0.5881
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPackage() 0 3 1
A getOptions() 0 3 1
A setOptions() 0 5 1
A getAvailableEventTypes() 0 6 1
A getType() 0 3 1
A __construct() 0 5 1
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\AnnotationChart\AnnotationChartOptions;
8
9
/**
10
 * @author Christophe Meneses
11
 */
12
class AnnotationChart extends Chart
13
{
14
    /**
15
     * @var AnnotationChartOptions
16
     */
17
    protected $options;
18
19 1
    public function __construct()
20
    {
21 1
        parent::__construct();
22
23 1
        $this->options = new AnnotationChartOptions();
24 1
    }
25
26 1
    public function getType()
27
    {
28 1
        return 'AnnotationChart';
29
    }
30
31 1
    public function getPackage()
32
    {
33 1
        return 'annotationchart';
34
    }
35
36
    public function getAvailableEventTypes()
37
    {
38
        return [
39
            EventType::RANGE_CHANGE,
40
            EventType::READY,
41
            EventType::SELECT,
42
        ];
43
    }
44
45
    /**
46
     * @return AnnotationChartOptions
47
     */
48 1
    public function getOptions()
49
    {
50 1
        return $this->options;
51
    }
52
53
    /**
54
     * @param AnnotationChartOptions $options
55
     *
56
     * @return AnnotationChart
57
     */
58
    public function setOptions($options)
59
    {
60
        $this->options = $options;
61
62
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type CMEN\GoogleChartsBundle\...\Charts\AnnotationChart 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...
63
    }
64
}
65