Completed
Push — master ( f4ee71...8ccc11 )
by Povilas
02:10
created

HintList   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHintsByValue() 0 11 3
A hasHints() 0 4 1
A addClassCont() 0 7 1
1
<?php
2
3
namespace Povils\PHPMND;
4
5
/**
6
 * Class HintList
7
 *
8
 * @package Povils\PHPMND
9
 */
10
class HintList
11
{
12
    /**
13
     * @var array
14
     */
15
    private $constants = [];
16
17
    /**
18
     * @param mixed $magicNumber
19
     *
20
     * @return array
21
     */
22
    public function getHintsByValue($magicNumber)
23
    {
24
        $hints = [];
25
        foreach ($this->constants as $constant) {
26
            if ($constant['value'] === $magicNumber) {
27
                $hints[] = $constant['hint'];
28
            }
29
        }
30
31
        return $hints;
32
    }
33
34
    /**
35
     * @return bool
36
     */
37
    public function hasHints()
38
    {
39
        return false === empty($this->constants);
40
    }
41
42
    /**
43
     * @param mixed  $value
44
     * @param string $className
45
     * @param string $constName
46
     */
47
    public function addClassCont($value, $className, $constName)
48
    {
49
        $this->constants[] = [
50
            'value' => $value,
51
            'hint' => sprintf('%s::%s', $className, $constName)
52
        ];
53
    }
54
}
55