OrgChart   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 48
ccs 0
cts 20
cp 0
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setOptions() 0 5 1
A __construct() 0 5 1
A getOptions() 0 3 1
A getType() 0 3 1
A getPackage() 0 3 1
A getAvailableEventTypes() 0 8 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\ChartOptionsInterface;
8
use CMEN\GoogleChartsBundle\GoogleCharts\Options\OrgChart\OrgChartOptions;
9
10
/**
11
 * @author Christophe Meneses
12
 */
13
class OrgChart extends Chart
14
{
15
    /**
16
     * @var OrgChartOptions
17
     */
18
    protected ChartOptionsInterface $options;
19
20
    public function __construct()
21
    {
22
        parent::__construct();
23
24
        $this->options = new OrgChartOptions();
25
    }
26
27
    public function getType(): string
28
    {
29
        return 'OrgChart';
30
    }
31
32
    public function getPackage(): string
33
    {
34
        return 'orgchart';
35
    }
36
37
    public function getAvailableEventTypes(): array
38
    {
39
        return [
40
            EventType::COLLAPSE,
41
            EventType::ON_MOUSE_OUT,
42
            EventType::ON_MOUSE_OVER,
43
            EventType::READY,
44
            EventType::SELECT,
45
        ];
46
    }
47
48
    public function getOptions(): OrgChartOptions
49
    {
50
        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\...rgChart\OrgChartOptions.
Loading history...
51
    }
52
53
    /**
54
     * @param OrgChartOptions $options
55
     */
56
    public function setOptions(ChartOptionsInterface $options): OrgChart
57
    {
58
        $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\...rgChart\OrgChartOptions. 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...
59
60
        return $this;
61
    }
62
}
63