EnumerationType::getOptionType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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
}