respect-validation/library/Rules/Identical.php

42 lines
710 B
PHP
Raw Normal View History

2015-10-13 18:27:49 +02:00
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
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;
}
}