Completed
Push — development ( 1fb984...7ea9e3 )
by Nils
08:29
created

Option::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PasswordGenerator\Model\Option;
4
5
6
require_once(dirname(__FILE__).'/OptionInterface.php');
7
8
abstract class Option implements OptionInterface
9
{
10
    const TYPE_BOOLEAN = 'boolean';
11
    const TYPE_INTEGER = 'integer';
12
    const TYPE_STRING = 'string';
13
14
    private $value = null;
15
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function __construct(array $settings = array())
20
    {
21
        if (isset($settings['default'])) {
22
            $this->value = $settings['default'];
23
        }
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getValue()
30
    {
31
        return $this->value;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function setValue($value)
38
    {
39
        $this->value = $value;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public static function createFromType($type, array $settings = array())
46
    {
47
        require_once(dirname(__FILE__).'/StringOption.php');
48
        require_once(dirname(__FILE__).'/IntegerOption.php');
49
        require_once(dirname(__FILE__).'/BooleanOption.php');
50
51
        switch ($type) {
52
            case self::TYPE_STRING:
53
                return new StringOption($settings);
54
55
            case self::TYPE_INTEGER:
56
                return new IntegerOption($settings);
57
58
            case self::TYPE_BOOLEAN:
59
                return new BooleanOption($settings);
60
        }
61
62
        return;
63
    }
64
}
65