for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace SimpleSAML\XML\Assert;
use InvalidArgumentException;
/**
* @package simplesamlphp/xml-common
*/
trait ShortTrait
{
/** @var string */
private static string $short_regex = '/^(((-[0]*([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[12][0-9]{4}|3[01][0-9]{3}|32[0-6][0-9]{2}|327[0-5][0-9]|3276[0-8]))|([+]?[0]*([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[12][0-9]{4}|3[01][0-9]{3}|32[0-6][0-9]{2}|327[0-5][0-9]|3276[0-7]))|0))$/D';
* @param string $value
* @param string $message
protected static function validShort(string $value, string $message = ''): void
parent::regex(
$value,
self::$short_regex,
$message ?: '%s is not a valid xs:short',
InvalidArgumentException::class,
);
}