MixedColorProvider::next()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
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
}