respect-validation/library/Rules/Identical.php

46 lines
850 B
PHP
Raw Normal View History

2015-10-13 18:27:49 +02:00
<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
2015-10-13 18:27:49 +02:00
*/
declare(strict_types=1);
2015-10-13 18:27:49 +02:00
namespace Respect\Validation\Rules;
/**
* Validates if the input is identical to some value.
*
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class Identical extends AbstractRule
2015-10-13 18:27:49 +02:00
{
/**
* @var mixed
*/
private $compareTo;
2015-10-13 18:27:49 +02:00
/**
* Initializes the rule.
*
* @param mixed $compareTo
*/
2015-10-13 18:27:49 +02:00
public function __construct($compareTo)
{
$this->compareTo = $compareTo;
}
/**
* {@inheritDoc}
*/
public function validate($input): bool
2015-10-13 18:27:49 +02:00
{
return $input === $this->compareTo;
}
}