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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
/**
* Validates whether a value match or not given regexp pattern.
*
* @author Bernhard Schussek <[email protected]>
* @author Joseph Bielawski <[email protected]>
*/
class RegexValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint)
{
if (!$constraint instanceof Regex) {
throw new UnexpectedTypeException($constraint, Regex::class);
}
if (null === $value || '' === $value) {
return;
}
if (!\is_scalar($value) && !$value instanceof \Stringable) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (null !== $constraint->normalizer) {
$value = ($constraint->normalizer)($value);
}
if ($constraint->match xor preg_match($constraint->pattern, $value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Regex::REGEX_FAILED_ERROR)
->addViolation();
}
}
}
?>
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 Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
/**
* Validates whether a value match or not given regexp pattern.
*
* @author Bernhard Schussek <[email protected]>
* @author Joseph Bielawski <[email protected]>
*/
class RegexValidator extends ConstraintValidator
{
public function validate(mixed $value, Constraint $constraint)
{
if (!$constraint instanceof Regex) {
throw new UnexpectedTypeException($constraint, Regex::class);
}
if (null === $value || '' === $value) {
return;
}
if (!\is_scalar($value) && !$value instanceof \Stringable) {
throw new UnexpectedValueException($value, 'string');
}
$value = (string) $value;
if (null !== $constraint->normalizer) {
$value = ($constraint->normalizer)($value);
}
if ($constraint->match xor preg_match($constraint->pattern, $value)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(Regex::REGEX_FAILED_ERROR)
->addViolation();
}
}
}
Function Calls
None |
Stats
MD5 | 295d8d5764e6c634d339837cc006f5c1 |
Eval Count | 0 |
Decode Time | 108 ms |