MixedColorProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 28
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A next() 0 6 2
1
<?php
2
namespace rtens\domin\delivery\web\renderers\charting\coloring;
3
4
use rtens\domin\parameters\Color;
5
6
class MixedColorProvider implements ColorProvider {
7
8
    private $colors;
9
10
    public function __construct() {
11
        $this->colors = [
12
            Color::BLUE(),
13
            Color::GREEN(),
14
            Color::RED(),
15
            Color::PURPLE(),
16
            Color::ORANGE(),
17
            Color::BROWN(),
18
            Color::PINK(),
19
            Color::YELLOW(),
20
            Color::GRAY()
21
        ];
22
    }
23
24
    /**
25
     * @return Color
26
     */
27
    public function next() {
28
        if (!$this->colors) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->colors of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
29
            return Color::RANDOM();
30
        }
31
        return array_shift($this->colors);
32
    }
33
}