/** * @param string|null $uuid */ public function __construct($uuid = null) { if (null == $uuid) { $uuid = UuidGenerator::uuid4()->toString(); } $validator = new Uuidv4(); if (!$validator->isSatisfiedBy($uuid)) { throw new \InvalidArgumentException("'{$uuid}' is not a valid uuid."); } $this->value = $uuid; }
/** * @test * @group unit */ public function invalid_uuid_returns_false() { $validator = new Uuidv4(); $validUuid = 'invalid'; $this->assertFalse($validator->isSatisfiedBy($validUuid)); }