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