Skip to content

Commit 348757a

Browse files
authored
Removed UUID from Generator to be able to extend it (#441)
Co-authored-by: Pim Jansen <[email protected]>
1 parent 3a50490 commit 348757a

File tree

3 files changed

+14
-33
lines changed

3 files changed

+14
-33
lines changed

Diff for: roave-bc-check.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ parameters:
88
- '#\[BC\] CHANGED: The parameter \$generator of Faker\\UniqueGenerator\#\_\_construct\(\) changed from Faker\\Generator to no type#'
99
- '#\[BC\] CHANGED: The return type of Faker\\Extension\\PersonExtension\#name\(\) changed from no type to string#'
1010
- '#\[BC\] CHANGED: The parameter \$max of Faker\\Extension\\NumberExtension\#randomFloat\(\) changed from float to float\|null#'
11+
- '#\[BC\] REMOVED: Method Faker\\Generator\#uuid\(\) was removed#'
12+
- '#\[BC\] REMOVED: Method Faker\\Generator\#uuid3\(\) was removed#'

Diff for: src/Faker/Generator.php

-28
Original file line numberDiff line numberDiff line change
@@ -797,34 +797,6 @@ public function bloodGroup(): string
797797
return $this->ext(Extension\BloodExtension::class)->bloodGroup();
798798
}
799799

800-
/**
801-
* Get a random v3 uuid
802-
*
803-
* @example '7e57d004-2b97-0e7a-b45f-5387367791cd'
804-
*
805-
* @deprecated call uuid3() instead
806-
*/
807-
public function uuid(): string
808-
{
809-
trigger_deprecation(
810-
'fakerphp/faker',
811-
'1.18',
812-
'Method uuid() is deprecated, call uuid3() instead'
813-
);
814-
815-
return $this->uuid3();
816-
}
817-
818-
/**
819-
* Get a random v3 uuid
820-
*
821-
* @example '7e57d004-2b97-0e7a-b45f-5387367791cd'
822-
*/
823-
public function uuid3(): string
824-
{
825-
return $this->ext(Extension\UuidExtension::class)->uuid3();
826-
}
827-
828800
/**
829801
* Get a random EAN13 barcode.
830802
*

Diff for: test/Faker/Core/UuidTest.php

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,35 @@
22

33
namespace Faker\Test\Core;
44

5+
use Faker\Core\Uuid;
56
use Faker\Test\TestCase;
67

78
final class UuidTest extends TestCase
89
{
910
public function testUuidReturnsUuid()
1011
{
11-
$uuid = $this->faker->uuid3();
12+
$instance = new Uuid();
13+
$uuid = $instance->uuid3();
1214
self::assertTrue($this->isUuid($uuid));
1315
}
1416

1517
public function testUuidExpectedSeed()
1618
{
19+
$instance = new Uuid();
20+
1721
if (pack('L', 0x6162797A) == pack('N', 0x6162797A)) {
1822
self::markTestSkipped('Big Endian');
1923
}
2024
$this->faker->seed(123);
21-
self::assertEquals('8e2e0c84-50dd-367c-9e66-f3ab455c78d6', $this->faker->uuid3());
22-
self::assertEquals('073eb60a-902c-30ab-93d0-a94db371f6c8', $this->faker->uuid3());
25+
self::assertEquals('8e2e0c84-50dd-367c-9e66-f3ab455c78d6', $instance->uuid3());
26+
self::assertEquals('073eb60a-902c-30ab-93d0-a94db371f6c8', $instance->uuid3());
2327
}
2428

25-
protected function isUuid($uuid)
29+
protected function isUuid(string $uuid)
2630
{
27-
return is_string($uuid) && (bool) preg_match('/^[a-f0-9]{8,8}-(?:[a-f0-9]{4,4}-){3,3}[a-f0-9]{12,12}$/i', $uuid);
31+
return is_string($uuid) && (bool) preg_match(
32+
'/^[a-f0-9]{8,8}-(?:[a-f0-9]{4,4}-){3,3}[a-f0-9]{12,12}$/i',
33+
$uuid
34+
);
2835
}
2936
}

0 commit comments

Comments
 (0)