EnumerationType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOptions() 0 3 1
A is() 0 3 1
A __toString() 0 3 1
A getOptionType() 0 3 1
1
<?php
2
namespace rtens\domin\reflection\types;
3
4
use watoki\reflect\Type;
5
6
class EnumerationType implements Type {
7
8
    private $options;
9
10
    private $optionType;
11
12
    /**
13
     * @param array $options
14
     * @param Type $optionType
15
     */
16
    public function __construct(array $options, Type $optionType) {
17
        $this->options = $options;
18
        $this->optionType = $optionType;
19
    }
20
21
    /**
22
     * @return array key/value pairs
23
     */
24
    public function getOptions() {
25
        return $this->options;
26
    }
27
28
    public function is($value) {
29
        return array_key_exists($value, $this->getOptions());
30
    }
31
32
    public function __toString() {
33
        return $this->optionType . '[]';
34
    }
35
36
    /**
37
     * @return Type
38
     */
39
    public function getOptionType() {
40
        return $this->optionType;
41
    }
42
}