Mappings::string()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace PhpWinTools\WmiScripting\MappingStrings;
4
5
abstract class Mappings
6
{
7
    const STRING_ARRAY_CONSTANT_NAME = 'STRING_ARRAY';
8
9
    const STRING_ARRAY = [];
10
11
    public static function string(string $constant): string
12
    {
13
        $string_constant = static::STRING_ARRAY_CONSTANT_NAME;
14
15
        if (array_key_exists($constant, constant(get_called_class() . "::{$string_constant}"))) {
16
            return constant(get_called_class() . "::{$string_constant}")[$constant];
17
        }
18
19
        return '';
20
    }
21
}
22