SymfonyConsoleDiDto::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 3
crap 2
1
<?php
2
/**
3
 * This file is part of the Symfony Console DI package.
4
 *
5
 * (c) Stéphane Demonchaux <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SymfonyDiConsole;
11
12
use Symfony\Component\Console\Input\InputDefinition;
13
use Symfony\Component\Console\Input\InputOption;
14
use Symfony\Component\Console\Input\InputArgument;
15
16
class SymfonyConsoleDiDto
17
{
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
    /**
23
     * @var string
24
     */
25
    private $description;
26
    /**
27
     * @var InputDefinition
28
     */
29
    private $definition;
30
31
    /**
32
     * @param string          $name
33
     * @param string          $description
34
     * @param InputDefinition $inputDefinition
35
     */
36 3
    public function __construct($name = null, $description = null, InputDefinition $inputDefinition = null)
37
    {
38 3
        $this->name        = $name;
39 3
        $this->description = $description;
40 3
        $this->definition  = $inputDefinition === null ? new InputDefinition() : $inputDefinition;
41 3
    }
42
43
    /**
44
     * @param string $name
45
     * @return SymfonyConsoleDiDto
46
     */
47 1
    public function setName($name)
48
    {
49 1
        $this->name = $name;
50
51 1
        return $this;
52
    }
53
54
    /**
55
     * @param string $name
56
     * @return SymfonyConsoleDiDto
57
     */
58 1
    public function setDescription($description)
59
    {
60 1
        $this->description = $description;
61
62 1
        return $this;
63
    }
64
65
    /**
66
     * Adds an argument.
67
     *
68
     * @param string $name        The argument name
69
     * @param int    $mode        The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
70
     * @param string $description A description text
71
     * @param mixed  $default     The default value (for InputArgument::OPTIONAL mode only)
72
     *
73
     * @return Command The current instance
74
     */
75 3
    public function addArgument($name, $mode = null, $description = '', $default = null)
76
    {
77 3
        $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
78
79 3
        return $this;
80
    }
81
82
    /**
83
     * Adds an option.
84
     *
85
     * @param string $name        The option name
86
     * @param string $shortcut    The shortcut (can be null)
87
     * @param int    $mode        The option mode: One of the InputOption::VALUE_* constants
88
     * @param string $description A description text
89
     * @param mixed  $default     The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
90
     *
91
     * @return Command The current instance
92
     */
93 3
    public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
94
    {
95 3
        $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
96
97 3
        return $this;
98
    }
99
100
    /**
101
     * @return string
102
     */
103 3
    public function getName()
104
    {
105 3
        return $this->name;
106
    }
107
108
    /**
109
     * @return string
110
     */
111 3
    public function getDescription()
112
    {
113 3
        return $this->description;
114
    }
115
116
    /**
117
     * @return InputDefinition
118
     */
119 3
    public function getDefinition()
120
    {
121 3
        return $this->definition;
122
    }
123
}
124