|
Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/www/kite.mata-lashes.com/vendor/rector/rector/src/Validation/ |
Upload File : |
<?php
declare (strict_types=1);
namespace Rector\Core\Validation;
use Rector\Core\Util\StringUtils;
use RectorPrefix20211231\Webmozart\Assert\InvalidArgumentException;
/**
* @see \Rector\Core\Tests\Validation\RectorAssertTest
*/
final class RectorAssert
{
/**
* @see https://stackoverflow.com/a/12011255/1348344
* @see https://regex101.com/r/PYQaPF/1
* @var string
*/
public const CLASS_NAME_REGEX = '#^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*$#';
/**
* Assert value is valid class name
*/
public static function className(string $className) : void
{
if (\Rector\Core\Util\StringUtils::isMatch($className, self::CLASS_NAME_REGEX)) {
return;
}
$errorMessage = $className . ' is not a valid class name';
throw new \RectorPrefix20211231\Webmozart\Assert\InvalidArgumentException($errorMessage);
}
}