Option::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * Copyright (c) 2015 Juan José Torroglosa Ramón
4
 *
5
 * This file is part of the Cliphar package.
6
 *
7
 * For the full copyright and license information, please view
8
 * the LICENSE file that was distributed with this source code.
9
 */
10
11
namespace Cliphar\InputDefinition\Model;
12
13
class Option
14
{
15
    /**
16
     * @var bool
17
     */
18
    private $isRequired;
19
    /**
20
     * @var string
21
     */
22
    private $name;
23
    /**
24
     * @var string
25
     */
26
    private $abbreviatedName;
27
    /**
28
     * @var string
29
     */
30
    private $defaultValue;
31
32
33
    /**
34
     * Option constructor.
35
     * @param boolean $isRequired
36
     * @param string $name
37
     * @param string $abbreviatedName
38
     * @param string $defaultValue
39
     */
40
    public function __construct($isRequired, $name, $abbreviatedName, $defaultValue)
41
    {
42
        $this->isRequired = $isRequired;
43
        $this->name = $name;
44
        $this->abbreviatedName = $abbreviatedName;
45
        $this->defaultValue = $defaultValue;
46
    }
47
48
    /**
49
     * @return boolean
50
     */
51
    public function isRequired()
52
    {
53
        return $this->isRequired && !$this->hasDefaultValue();
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getName()
60
    {
61
        return $this->name;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getAbbreviatedName()
68
    {
69
        return $this->abbreviatedName;
70
    }
71
72
    /**
73
     * @return bool
74
     */
75
    public function hasAbbreviatedName()
76
    {
77
        return $this->abbreviatedName !== null
78
            && $this->abbreviatedName !== "";
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getDefaultValue()
85
    {
86
        return $this->defaultValue;
87
    }
88
89
    /**
90
     * @return bool
91
     */
92
    public function hasDefaultValue()
93
    {
94
        return $this->defaultValue !== null;
95
    }
96
}