mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
b4dff559ab
* Assert, for psalm, the string is non-empty if validation passes * Adds a test for SA asserting that valid string are also non-empty * Suppress PHPStan error for unsupported conditional type assertion * Check SA tools don't complain about non-empty-string as input parameter to `Uuid::isValid()`
36 lines
729 B
PHP
36 lines
729 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Ramsey\Uuid\StaticAnalysis;
|
|
|
|
use InvalidArgumentException;
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
final class ValidUuidIsNonEmpty
|
|
{
|
|
/** @return non-empty-string */
|
|
public function validUuidsAreNotEmpty(string $input): string
|
|
{
|
|
if (Uuid::isValid($input)) {
|
|
return $input;
|
|
}
|
|
|
|
throw new InvalidArgumentException('Not a UUID');
|
|
}
|
|
|
|
/**
|
|
* @param non-empty-string $input
|
|
*
|
|
* @return non-empty-string
|
|
*/
|
|
public function givenNonEmptyInputAssertionRemainsValid(string $input): string
|
|
{
|
|
if (Uuid::isValid($input)) {
|
|
return $input;
|
|
}
|
|
|
|
throw new InvalidArgumentException('Not a UUID');
|
|
}
|
|
}
|