Argument::getDefaultValue()   A
last analyzed

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
 * 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
14
class Argument
15
{
16
    /**
17
     * @var string
18
     */
19
    private $name;
20
    /**
21
     * @var boolean
22
     */
23
    private $required;
24
25
    /**
26
     * @var string
27
     */
28
    private $defaultValue;
29
30
    /**
31
     * Argument constructor.
32
     * @param string $name
33
     * @param bool $required
34
     * @param string $defaultValue
35
     */
36
    public function __construct($name, $required, $defaultValue)
37
    {
38
        $this->name = $name;
39
        $this->required = $required;
40
        $this->defaultValue = $defaultValue;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getName()
47
    {
48
        return $this->name;
49
    }
50
51
    /**
52
     * @return boolean
53
     */
54
    public function isRequired()
55
    {
56
        return $this->required && !$this->hasDefaultValue();
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getDefaultValue()
63
    {
64
        return $this->defaultValue;
65
    }
66
67
    public function hasDefaultValue()
68
    {
69
        return $this->defaultValue !== null;
70
    }
71
}