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