ChartOption   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 55
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __call() 0 7 1
A __get() 0 10 2
A __isset() 0 6 1
1
<?php
2
3
namespace Muspelheim\C3ChartsBundle\C3;
4
5
/**
6
 * Class ChartOption
7
 * @package Muspelheim\C3ChartsBundle\C3
8
 */
9
class ChartOption
10
{
11
    private $option;
12
13
    /**
14
     * @param string $name
15
     */
16
    public function __construct(string $name)
17
    {
18
        $this->option = $name;
19
        $this->{$name} = new \stdClass();
20
    }
21
22
    /**
23
     * @param string $name
24
     * @param array  $value
25
     *
26
     * @return $this
27
     */
28
    public function __call(string $name, array $value): ChartOption
29
    {
30
        $option = $this->option;
31
        $this->{$option}->{$name} = $value[0];
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param string $name
38
     *
39
     * @return mixed
40
     */
41
    public function __get($name)
42
    {
43
        $option = $this->option;
44
        if (!property_exists($this->{$option}, $name)) {
45
            $this->{$option}->{$name} = new static($name);
46
        }
47
        $value = $this->{$option}->{$name};
48
49
        return $value;
50
    }
51
52
    /**
53
     * @param string $name
54
     *
55
     * @return bool
56
     */
57
    public function __isset($name): bool
58
    {
59
        $option = $this->option;
60
        
61
        return isset($this->{$option}->{$name});
62
    }
63
}
64