#301·uuid

[4.0] UuidVX::fromString should fail if provided string belongs to a different version

Author: jacekkarczmarczykCreated Mar 23, 2020Updated Mar 24, 2020
Labelsbug

Describe the bug

Specific version factory, unlike the general one (RamsayUuid::uuidX()) should fail if provided string belongs to a different version

To Reproduce...

php
        $uuid4String = RamseyUuid::uuid4()->toString();
        $uuid = UuidV1::fromString($uuid4String);
        assert($uuid instanceof UuidV1);

Expected behavior

UuidV1::fromString should throw InvalidArgumentException

Screenshots or output

  • UuidV1::fromString returns instance of UuidV4
  • assert fails

Environment details

  • OS: Windows 10
  • PHP version: 7.4
  • ramsey/uuid version: 4.0