27
27
use Opengento \Gdpr \Model \Customer \OrigDataRegistry ;
28
28
use Opengento \Gdpr \Service \Anonymize \AnonymizerInterface ;
29
29
use Opengento \Gdpr \Service \Erase \ProcessorInterface ;
30
+ use Random \RandomException ;
30
31
31
- use function mt_rand ;
32
+ use function random_int ;
32
33
use function sha1 ;
33
34
use function uniqid ;
34
35
@@ -50,18 +51,18 @@ public function __construct(
50
51
) {}
51
52
52
53
/**
53
- * @inheritdoc
54
54
* @throws LocalizedException
55
+ * @throws RandomException
55
56
*/
56
- public function execute (int $ customerId ): bool
57
+ public function execute (int $ entityId ): bool
57
58
{
58
59
try {
59
- $ this ->processCustomerData ($ customerId );
60
- } catch (NoSuchEntityException $ e ) {
60
+ $ this ->processCustomerData ($ entityId );
61
+ } catch (NoSuchEntityException ) {
61
62
return false ;
62
63
}
63
64
64
- $ this ->sessionCleaner ->clearFor ($ customerId );
65
+ $ this ->sessionCleaner ->clearFor ($ entityId );
65
66
66
67
return true ;
67
68
}
@@ -71,6 +72,7 @@ public function execute(int $customerId): bool
71
72
* @throws InputMismatchException
72
73
* @throws LocalizedException
73
74
* @throws NoSuchEntityException
75
+ * @throws RandomException
74
76
*/
75
77
private function processCustomerData (int $ customerId ): void
76
78
{
@@ -98,6 +100,7 @@ private function fetchOrdersList(CustomerInterface $customer): OrderSearchResult
98
100
* @throws NoSuchEntityException
99
101
* @throws InputException
100
102
* @throws InputMismatchException
103
+ * @throws RandomException
101
104
*/
102
105
private function anonymizeCustomer (CustomerInterface $ customer ): void
103
106
{
@@ -106,7 +109,7 @@ private function anonymizeCustomer(CustomerInterface $customer): void
106
109
$ secureData = $ this ->customerRegistry ->retrieveSecureData ($ customer ->getId ());
107
110
$ dateTime = (new DateTime ())->setTimestamp (PHP_INT_MAX );
108
111
$ secureData ->setData ('lock_expires ' , $ dateTime ->format (DateTimeFormat::DATETIME_PHP_FORMAT ));
109
- $ secureData ->setPasswordHash (sha1 (uniqid ((string )mt_rand (), true )));
112
+ $ secureData ->setPasswordHash (sha1 (uniqid ((string )random_int (), true )));
110
113
111
114
$ customer = $ this ->anonymizer ->anonymize ($ customer );
112
115
if ($ customer instanceof DataObject) {
0 commit comments