respect-validation/library/Rules/ArrayVal.php
Emmerson Siqueira 2bcc164b35
Apply contribution guidelines to "ArrayVal" rule
Signed-off-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
2018-04-02 23:19:22 +02:00

35 lines
852 B
PHP

<?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.md"
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use ArrayAccess;
use SimpleXMLElement;
/**
* Validates if the input is an array or if the input can be used as an array (instance of `ArrayAccess` or `SimpleXMLElement`).
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class ArrayVal extends AbstractRule
{
/**
* {@inheritdoc}
*/
public function validate($input): bool
{
return is_array($input) || $input instanceof ArrayAccess || $input instanceof SimpleXMLElement;
}
}