Install zendframework via composer, update build.xml and run, updates to composer
[openemr.git] / vendor / zendframework / zendframework / library / Zend / Console / Prompt / Confirm.php
blob6746579031130a516188e32ac01fd745eade5989
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Console\Prompt;
12 class Confirm extends Char
14 /**
15 * @var string
17 protected $promptText = 'Are you sure?';
19 /**
20 * @var string
22 protected $allowedChars = 'yn';
24 /**
25 * @var string
27 protected $yesChar = 'y';
29 /**
30 * @var string
32 protected $noChar = 'n';
34 /**
35 * @var bool
37 protected $ignoreCase = true;
39 /**
40 * Ask the user for a single key stroke
42 * @param string $promptText The prompt text to display in console
43 * @param string $yesChar The "yes" key (defaults to Y)
44 * @param string $noChar The "no" key (defaults to N)
46 public function __construct(
47 $promptText = 'Are you sure?',
48 $yesChar = 'y',
49 $noChar = 'n'
50 ) {
51 if ($promptText !== null) {
52 $this->setPromptText($promptText);
55 if ($yesChar !== null) {
56 $this->setYesChar($yesChar);
59 if ($noChar !== null) {
60 $this->setNoChar($noChar);
64 /**
65 * Show the confirmation message and return result.
67 * @return bool
69 public function show()
71 $char = parent::show();
72 if ($this->ignoreCase) {
73 $response = strtolower($char) === strtolower($this->yesChar);
74 } else {
75 $response = $char === $this->yesChar;
77 return $this->lastResponse = $response;
80 /**
81 * @param string $noChar
83 public function setNoChar($noChar)
85 $this->noChar = $noChar;
86 $this->setAllowedChars($this->yesChar . $this->noChar);
89 /**
90 * @return string
92 public function getNoChar()
94 return $this->noChar;
97 /**
98 * @param string $yesChar
100 public function setYesChar($yesChar)
102 $this->yesChar = $yesChar;
103 $this->setAllowedChars($this->yesChar . $this->noChar);
107 * @return string
109 public function getYesChar()
111 return $this->yesChar;