DataPointChart   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 32.26 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 10
loc 31
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A data() 10 10 2
A getDataPoints() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace rtens\domin\delivery\web\renderers\charting\charts;
3
4
use rtens\domin\delivery\web\renderers\charting\Chart;
5
use rtens\domin\delivery\web\renderers\charting\data\DataPoint;
6
7
abstract class DataPointChart extends Chart {
8
9
    /** @var DataPoint[] */
10
    private $dataPoints = [];
11
12
    /**
13
     * @param DataPoint[] $dataPoints
14
     */
15
    public function __construct(array $dataPoints = []) {
16
        parent::__construct();
17
        $this->dataPoints = $dataPoints;
18
    }
19
20 View Code Duplication
    public function data() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
        return array_map(function (DataPoint $point) {
22
            return array_merge(
23
                [
24
                    "label" => $point->getLabel(),
25
                    "value" => $point->getValue()
26
                ],
27
                $this->makePalette($point->getColor() ?: $this->provideColor()));
28
        }, $this->getDataPoints());
29
    }
30
31
    /**
32
     * @return DataPoint[]
33
     */
34
    public function getDataPoints() {
35
        return $this->dataPoints;
36
    }
37
}