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

Constant::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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