Test Failed
Push — master ( 12aea4...5981da )
by Nicolas
02:27
created

TypeProvider::getTypeByKey()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Cp\Provider;
4
5
use Cp\DomainObject\TypeInterface;
6
7
/**
8
 * Class Type
9
 */
10
class TypeProvider
11
{
12
    /**
13
     * @return array
14
     */
15 2
    public function getTypes()
16
    {
17
        return [
18 2
            '10' => TypeInterface::TYPE_10K,
19 2
            '21' => TypeInterface::TYPE_SEMI,
20 2
            '42' => TypeInterface::TYPE_MARATHON,
21 2
        ];
22
    }
23
24
    /**
25
     * @param string $type
26
     *
27
     * @return string|null
28
     */
29 1
    public function getTypeByName($type)
30
    {
31 1
        $key = array_search($type, $this->getTypes());
32
33 1
        return false !== $key ? $this->getTypes()[$key] : null;
34
    }
35
36
    /**
37
     * @param string $key
38
     *
39
     * @return string|null
40
     */
41
    public function getTypeByKey($key)
42
    {
43
        return isset($this->getTypes()[$key]) ? $this->getTypes()[$key] : null;
44
    }
45
}
46