lab/cacme/vendor/workerman/validation/library/Rules/File.php
2024-08-05 22:57:28 +08:00

37 lines
689 B
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use SplFileInfo;
use function is_file;
use function is_string;
/**
* Validates whether file input is as a regular filename.
*
* @author Danilo Correa <danilosilva87@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
*/
final class File extends AbstractRule
{
/**
* {@inheritDoc}
*/
public function validate($input): bool
{
if ($input instanceof SplFileInfo) {
return $input->isFile();
}
return is_string($input) && is_file($input);
}
}