Skip to content

Commit 9fbc6a4

Browse files
[Uid] Remove InvalidU*idException in favor of InvalidArgumentException
1 parent 94f4d7a commit 9fbc6a4

File tree

5 files changed

+5
-49
lines changed

5 files changed

+5
-49
lines changed

src/Symfony/Component/Uid/Exception/InvalidUlidException.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Symfony/Component/Uid/Exception/InvalidUuidException.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/Symfony/Component/Uid/Tests/UlidTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Uid\Exception\InvalidArgumentException;
16-
use Symfony\Component\Uid\Exception\InvalidUlidException;
1716
use Symfony\Component\Uid\MaxUlid;
1817
use Symfony\Component\Uid\NilUlid;
1918
use Symfony\Component\Uid\Tests\Fixtures\CustomUlid;
@@ -43,7 +42,7 @@ public function testGenerate()
4342

4443
public function testWithInvalidUlid()
4544
{
46-
$this->expectException(InvalidUlidException::class);
45+
$this->expectException(InvalidArgumentException::class);
4746
$this->expectExceptionMessage('Invalid ULID: "this is not a ulid".');
4847

4948
new Ulid('this is not a ulid');

src/Symfony/Component/Uid/Ulid.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Uid;
1313

1414
use Symfony\Component\Uid\Exception\InvalidArgumentException;
15-
use Symfony\Component\Uid\Exception\InvalidUlidException;
1615

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

4544
$this->uid = strtoupper($ulid);

src/Symfony/Component/Uid/Uuid.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Component\Uid;
1313

14-
use Symfony\Component\Uid\Exception\InvalidUuidException;
14+
use Symfony\Component\Uid\Exception\InvalidArgumentException;
1515

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

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

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

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

0 commit comments

Comments
 (0)