[TASK] Namespace classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Cli / CommandArgumentDefinition.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Cli;
3
4 /***************************************************************
5 * Copyright notice
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of FLOW3.
9 * All credits go to the v5 team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Represents a CommandArgumentDefinition
29 *
30 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
31 */
32 class CommandArgumentDefinition {
33
34 /**
35 * @var string
36 */
37 protected $name = '';
38
39 /**
40 * @var boolean
41 */
42 protected $required = FALSE;
43
44 /**
45 * @var string
46 */
47 protected $description = '';
48
49 /**
50 * Constructor
51 *
52 * @param string $name name of the command argument (= parameter name)
53 * @param boolean $required defines whether this argument is required or optional
54 * @param string $description description of the argument
55 * @author Bastian Waidelich <bastian@typo3.org>
56 */
57 public function __construct($name, $required, $description) {
58 $this->name = $name;
59 $this->required = $required;
60 $this->description = $description;
61 }
62
63 /**
64 * @return string
65 */
66 public function getName() {
67 return $this->name;
68 }
69
70 /**
71 * Returns the lowercased name with dashes as word separator
72 *
73 * @return string
74 */
75 public function getDashedName() {
76 $dashedName = ucfirst($this->name);
77 $dashedName = preg_replace('/([A-Z][a-z0-9]+)/', '$1-', $dashedName);
78 return '--' . strtolower(substr($dashedName, 0, -1));
79 }
80
81 /**
82 * @return string
83 */
84 public function getDescription() {
85 return $this->description;
86 }
87
88 /**
89 * @return string
90 */
91 public function isRequired() {
92 return $this->required;
93 }
94
95 }
96
97
98 ?>