Skip to content

Commit c3f6d48

Browse files
committed
Extract Anonymizable key retrieval into method
1 parent efef4e0 commit c3f6d48

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Anonymizable.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
interface Anonymizable
88
{
9+
/**
10+
* Get the key value used to ensure consistent fake data generation.
11+
*/
12+
public function getAnonymizableKey(): ?string;
13+
914
/**
1015
* Get the seed value used to ensure consistent fake data generation.
1116
*/

src/AnonymizesAttributes.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,20 @@ public function withoutAnonymization(callable $callback): mixed
4242
}
4343
}
4444

45+
/**
46+
* Get the key for the anonymizable instance.
47+
*/
48+
public function getAnonymizableKey(): ?string
49+
{
50+
return $this->getKey();
51+
}
52+
4553
/**
4654
* Get the seed for the anonymizable instance.
4755
*/
4856
public function getAnonymizableSeed(): string
4957
{
50-
return get_class($this).':'.$this->getKey();
58+
return get_class($this).':'.$this->getAnonymizableKey();
5159
}
5260

5361
/**

tests/AnonymizedJsonResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function getAnonymizedAttributes(Generator $faker): array
1919
];
2020
}
2121

22-
public function getAnonymizableSeed(): string
22+
public function getAnonymizableKey(): string
2323
{
2424
return 1;
2525
}

0 commit comments

Comments
 (0)