Completed
Push — master ( 1b6d66...884e6a )
by Adam
02:37
created

Constant   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 36
ccs 0
cts 13
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 5 2
A init() 0 4 1
1
<?php namespace BestServedCold\PhalueObjects\Utility\Native;
2
3
use BestServedCold\PhalueObjects\ValueObject;
4
use BestServedCold\PhalueObjects\ExtendedArray\ExtendedArrayTrait;
5
6
/**
7
 * Class Constants
8
 * @package BestServedCold\PhalueObjects\Utility\Native
9
 */
10
class Constant
11
{
12
    use ExtendedArrayTrait;
13
14
    /**
15
     * @var array
16
     */
17
    private $definedConstants;
18
19
    /**
20
     * Constants constructor.
21
     */
22
    public function __construct()
23
    {
24
        $this->definedConstants = get_defined_constants(true);
25
    }
26
27
    /**
28
     * @param $category
29
     * @param array $key
30
     * @return mixed
31
     */
32
    public function __call($category, array $key)
33
    {
34
        $category = $this->definedConstants[$category];
35
        return empty($key) ? $category : array_search(reset($key), $category);
36
    }
37
38
    /**
39
     * @return static
40
     */
41
    public static function init()
42
    {
43
        return new static;
44
    }
45
}
46