Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@..
Decoded Output download
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Console\Question;
/**
* Represents a yes/no question.
*
* @author Fabien Potencier <[email protected]>
*/
class ConfirmationQuestion extends Question
{
/**
* @var string
*/
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 = rue, 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 (alse === $default) {
return $answer && $answerIsTrue;
}
return '' === $answer || $answerIsTrue;
};
}
}
?>
Did this file decode correctly?
Original Code
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RectorPrefix202406\Symfony\Component\Console\Question;
/**
* Represents a yes/no question.
*
* @author Fabien Potencier <[email protected]>
*/
class ConfirmationQuestion extends Question
{
/**
* @var string
*/
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;
};
}
}
Function Calls
None |
Stats
MD5 | ca00c3c4b4cc0285460d0c66a3f391d5 |
Eval Count | 0 |
Decode Time | 95 ms |