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

TypeProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypes() 0 8 1
A getTypeByName() 0 6 2
A getTypeByKey() 0 4 2
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