Skip to content

Commit 340d759

Browse files
committed
fix #93 always return 1 row array
1 parent edfc1c3 commit 340d759

File tree

4 files changed

+44
-47
lines changed

4 files changed

+44
-47
lines changed

Model/Customer/Anonymize/Processor/CustomerDataProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private function anonymizeCustomer(int $customerId): void
131131
$secureData = $this->customerRegistry->retrieveSecureData($customerId);
132132
$dateTime = (new DateTime())->setTimestamp(PHP_INT_MAX);
133133
$secureData->setData('lock_expires', $dateTime->format(DateTimeFormat::DATETIME_PHP_FORMAT));
134-
$secureData->setPasswordHash(sha1(uniqid(mt_rand(), true)));
134+
$secureData->setPasswordHash(sha1(uniqid((string) mt_rand(), true)));
135135

136136
$this->customerRepository->save(
137137
$this->anonymizer->anonymize($this->customerRepository->getById($customerId))

Service/Anonymize/Anonymizer/ArrayValue.php

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © OpenGento, All rights reserved.
4+
* See LICENSE bundled with this library for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Opengento\Gdpr\Service\Anonymize\Anonymizer;
9+
10+
use Magento\Framework\Exception\LocalizedException;
11+
use Magento\Framework\Math\Random;
12+
use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface;
13+
use function sprintf;
14+
15+
final class Street implements AnonymizerInterface
16+
{
17+
private const STREET_LENGTH = 5;
18+
private const MIN_NUM = 0;
19+
private const MAX_NUM = 100;
20+
21+
/**
22+
* @var Random
23+
*/
24+
private $random;
25+
26+
public function __construct(
27+
Random $random
28+
) {
29+
$this->random = $random;
30+
}
31+
32+
/**
33+
* @throws LocalizedException
34+
*/
35+
public function anonymize($value): array
36+
{
37+
return [sprintf(
38+
'%s %s',
39+
Random::getRandomNumber(self::MIN_NUM, self::MAX_NUM),
40+
$this->random->getRandomString(self::STREET_LENGTH)
41+
)];
42+
}
43+
}

etc/di.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,6 @@
180180
</arguments>
181181
</virtualType>
182182
<!-- Anonymize Management -->
183-
<virtualType name="Opengento\Gdpr\Service\Anonymize\Anonymizer\Street" type="Opengento\Gdpr\Service\Anonymize\Anonymizer\ArrayValue">
184-
<arguments>
185-
<argument name="anonymizers" xsi:type="array">
186-
<item name="0" xsi:type="object">Opengento\Gdpr\Service\Anonymize\Anonymizer\Number</item>
187-
<item name="1" xsi:type="object">Opengento\Gdpr\Service\Anonymize\Anonymizer\AlphaLower</item>
188-
</argument>
189-
</arguments>
190-
</virtualType>
191183
<type name="Opengento\Gdpr\Service\Anonymize\AnonymizerFactory">
192184
<arguments>
193185
<argument name="anonymizers" xsi:type="array">

0 commit comments

Comments
 (0)