Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/Symfony/Component/Uid/Exception/InvalidUlidException.php

This file was deleted.

22 changes: 0 additions & 22 deletions src/Symfony/Component/Uid/Exception/InvalidUuidException.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Symfony/Component/Uid/Tests/UlidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Exception\InvalidArgumentException;
use Symfony\Component\Uid\Exception\InvalidUlidException;
use Symfony\Component\Uid\MaxUlid;
use Symfony\Component\Uid\NilUlid;
use Symfony\Component\Uid\Tests\Fixtures\CustomUlid;
Expand Down Expand Up @@ -43,7 +42,7 @@ public function testGenerate()

public function testWithInvalidUlid()
{
$this->expectException(InvalidUlidException::class);
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid ULID: "this is not a ulid".');

new Ulid('this is not a ulid');
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Uid/Ulid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\Uid;

use Symfony\Component\Uid\Exception\InvalidArgumentException;
use Symfony\Component\Uid\Exception\InvalidUlidException;

/**
* A ULID is lexicographically sortable and contains a 48-bit timestamp and 80-bit of crypto-random entropy.
Expand All @@ -39,7 +38,7 @@ public function __construct(?string $ulid = null)
$this->uid = $ulid;
} else {
if (!self::isValid($ulid)) {
throw new InvalidUlidException($ulid);
throw new InvalidArgumentException(\sprintf('Invalid ULID: "%s".', $ulid));
}

$this->uid = strtoupper($ulid);
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Uid/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Uid;

use Symfony\Component\Uid\Exception\InvalidUuidException;
use Symfony\Component\Uid\Exception\InvalidArgumentException;

/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
Expand Down Expand Up @@ -41,13 +41,13 @@ public function __construct(string $uuid, bool $checkVariant = false)
$type = preg_match('{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di', $uuid) ? (int) $uuid[14] : false;

if (false === $type || (static::TYPE ?: $type) !== $type) {
throw new InvalidUuidException(static::TYPE, $uuid);
throw new InvalidArgumentException(\sprintf('Invalid UUID%s: "%s".', static::TYPE ? 'v'.static::TYPE : '', $uuid));
}

$this->uid = strtolower($uuid);

if ($checkVariant && !\in_array($this->uid[19], ['8', '9', 'a', 'b'], true)) {
throw new InvalidUuidException(static::TYPE, $uuid);
throw new InvalidArgumentException(\sprintf('Invalid UUID%s: "%s".', static::TYPE ? 'v'.static::TYPE : '', $uuid));
}
}

Expand Down