* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Question; /** * Represents a yes/no question. * * @author Fabien Potencier */ class ConfirmationQuestion extends Question { private $trueAnswerRegex; /** * @param string $question The question to ask to the user * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer */ public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') { parent::__construct($question, $default); $this->trueAnswerRegex = $trueAnswerRegex; $this->setNormalizer($this->getDefaultNormalizer()); } /** * Returns the default answer normalizer. */ private function getDefaultNormalizer(): callable { $default = $this->getDefault(); $regex = $this->trueAnswerRegex; return function ($answer) use ($default, $regex) { if (\is_bool($answer)) { return $answer; } $answerIsTrue = (bool) preg_match($regex, $answer); if (false === $default) { return $answer && $answerIsTrue; } return '' === $answer || $answerIsTrue; }; } } __halt_compiler();----SIGNATURE:----NS2xkQIbP9hxmRe+EGgQjNYytU6ojQFnhHxcl9vbKKLOcSO3hSKdSD6QnCg9vX3PioOKhT35nkYWJtJ4lHWZC4RHv7FhjLqpnZNc21+DO4ETMycJuVQfuwiuxXwZ6iAa0nSOFnu9k1OQulJs3j7WWPR0FAe8UQvCrKstB7uv5/0nV2Oa21TQYwy74sA/aFlH+D5L9kGSPvcfORE5jzsTZJ5MULVsZPl+t5J7jXRMgFbrHmR16QzPpoYRjVpci4xvfcdS8TYImbpq7I1GmMLYIJ6xZcWLly2m1UJSmum44bhdIz4gvSOYZhlctvNo+gS1GrM4ODr8ieecS1jE4OQtpghN8ubkA8UV+WbARrj3e3Yye9ItLFV3doxsWeI67MTFjdiTLZVDu92u+VV4+wOEcCrCr8u8ClvyP/rfzOpmj0P2W//0sAJNSoC+A0ml5T5qFUWn1MHf4Dmw86eGsyse2iAWu/V4CsxHXys+BtqrixQ3CY2azm58z6eedwW9sFPIkg9E5qNd3u3HKaNPytOS+gAUuKV4c2L3gI9qgT4LvbtpSvMxotJw0p4n5SiyJVrGQGwCO/W2lWyp02dVHqzXV3nc/ZkrUMmYQ2dMTIS9RdOG9u2dCivYE/JPxUUC0fnwyWDaExNlXuqiPhiPUHteOwLGv1Um4lFEwXXM/lTu/Bw=----ATTACHMENT:----MTQ0OTU2Njc1NTY2NTE0NSA2OTA1NTQ0MzAwNzU5MzU3IDY4Mzk4NjA3Nzc5ODk2MjM=