InputRequest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. * $Id: InputRequest.php 905 2010-10-05 16:28:03Z mrook $
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. * This software consists of voluntary contributions made by many individuals
  18. * and is licensed under the LGPL. For more information please see
  19. * <http://phing.info>.
  20. */
  21. /**
  22. * Encapsulates an input request.
  23. *
  24. * @author Hans Lellelid <hans@xmpl.org> (Phing)
  25. * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
  26. * @version $Revision: 905 $
  27. * @package phing.input
  28. */
  29. class InputRequest {
  30. protected $prompt;
  31. protected $input;
  32. protected $defaultValue;
  33. protected $promptChar;
  34. /**
  35. * @param string $prompt The prompt to show to the user. Must not be null.
  36. */
  37. public function __construct($prompt) {
  38. if ($prompt === null) {
  39. throw new BuildException("prompt must not be null");
  40. }
  41. $this->prompt = $prompt;
  42. }
  43. /**
  44. * Retrieves the prompt text.
  45. */
  46. public function getPrompt() {
  47. return $this->prompt;
  48. }
  49. /**
  50. * Sets the user provided input.
  51. */
  52. public function setInput($input) {
  53. $this->input = $input;
  54. }
  55. /**
  56. * Is the user input valid?
  57. */
  58. public function isInputValid() {
  59. return true;
  60. }
  61. /**
  62. * Retrieves the user input.
  63. */
  64. public function getInput() {
  65. return $this->input;
  66. }
  67. /**
  68. * Set the default value to use.
  69. * @param mixed $v
  70. */
  71. public function setDefaultValue($v) {
  72. $this->defaultValue = $v;
  73. }
  74. /**
  75. * Return the default value to use.
  76. * @return mixed
  77. */
  78. public function getDefaultValue() {
  79. return $this->defaultValue;
  80. }
  81. /**
  82. * Set the default value to use.
  83. * @param string $c
  84. */
  85. public function setPromptChar($c) {
  86. $this->promptChar = $c;
  87. }
  88. /**
  89. * Return the default value to use.
  90. * @return string
  91. */
  92. public function getPromptChar() {
  93. return $this->promptChar;
  94. }
  95. }