diff --git a/src/Codec/StringCodec.php b/src/Codec/StringCodec.php index ea7b264..48d8c32 100644 --- a/src/Codec/StringCodec.php +++ b/src/Codec/StringCodec.php @@ -16,6 +16,7 @@ namespace Ramsey\Uuid\Codec; use InvalidArgumentException; use Ramsey\Uuid\Builder\UuidBuilderInterface; +use Ramsey\Uuid\Exception\InvalidUuidStringException; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidInterface; @@ -139,7 +140,7 @@ class StringCodec implements CodecInterface $nameParsed = implode('-', $components); if (!Uuid::isValid($nameParsed)) { - throw new InvalidArgumentException('Invalid UUID string: ' . $encodedUuid); + throw new InvalidUuidStringException('Invalid UUID string: ' . $encodedUuid); } return $components; diff --git a/src/Exception/InvalidUuidStringException.php b/src/Exception/InvalidUuidStringException.php new file mode 100644 index 0000000..0e48064 --- /dev/null +++ b/src/Exception/InvalidUuidStringException.php @@ -0,0 +1,22 @@ + + * @license http://opensource.org/licenses/MIT MIT + * @link https://benramsey.com/projects/ramsey-uuid/ Documentation + * @link https://packagist.org/packages/ramsey/uuid Packagist + * @link https://github.com/ramsey/uuid GitHub + */ + +namespace Ramsey\Uuid\Exception; + +/** + * Thrown to indicate that the parsed UUID string is invalid. + */ +class InvalidUuidStringException extends \InvalidArgumentException +{ +} diff --git a/tests/UuidTest.php b/tests/UuidTest.php index 0430198..d4273fa 100644 --- a/tests/UuidTest.php +++ b/tests/UuidTest.php @@ -80,7 +80,7 @@ class UuidTest extends TestCase } /** - * @expectedException InvalidArgumentException + * @expectedException \Ramsey\Uuid\Exception\InvalidUuidStringException * @expectedExceptionMessage Invalid UUID string: */ public function testFromStringWithInvalidUuidString()