Skip to content

Commit

Permalink
fix #93 always return 1 row array
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed May 13, 2021
1 parent edfc1c3 commit 340d759
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function anonymizeCustomer(int $customerId): void
$secureData = $this->customerRegistry->retrieveSecureData($customerId);
$dateTime = (new DateTime())->setTimestamp(PHP_INT_MAX);
$secureData->setData('lock_expires', $dateTime->format(DateTimeFormat::DATETIME_PHP_FORMAT));
$secureData->setPasswordHash(sha1(uniqid(mt_rand(), true)));
$secureData->setPasswordHash(sha1(uniqid((string) mt_rand(), true)));

$this->customerRepository->save(
$this->anonymizer->anonymize($this->customerRepository->getById($customerId))
Expand Down
38 changes: 0 additions & 38 deletions Service/Anonymize/Anonymizer/ArrayValue.php

This file was deleted.

43 changes: 43 additions & 0 deletions Service/Anonymize/Anonymizer/Street.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/
declare(strict_types=1);

namespace Opengento\Gdpr\Service\Anonymize\Anonymizer;

use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Math\Random;
use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface;
use function sprintf;

final class Street implements AnonymizerInterface
{
private const STREET_LENGTH = 5;
private const MIN_NUM = 0;
private const MAX_NUM = 100;

/**
* @var Random
*/
private $random;

public function __construct(
Random $random
) {
$this->random = $random;
}

/**
* @throws LocalizedException
*/
public function anonymize($value): array
{
return [sprintf(
'%s %s',
Random::getRandomNumber(self::MIN_NUM, self::MAX_NUM),
$this->random->getRandomString(self::STREET_LENGTH)
)];
}
}
8 changes: 0 additions & 8 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@
</arguments>
</virtualType>
<!-- Anonymize Management -->
<virtualType name="Opengento\Gdpr\Service\Anonymize\Anonymizer\Street" type="Opengento\Gdpr\Service\Anonymize\Anonymizer\ArrayValue">
<arguments>
<argument name="anonymizers" xsi:type="array">
<item name="0" xsi:type="object">Opengento\Gdpr\Service\Anonymize\Anonymizer\Number</item>
<item name="1" xsi:type="object">Opengento\Gdpr\Service\Anonymize\Anonymizer\AlphaLower</item>
</argument>
</arguments>
</virtualType>
<type name="Opengento\Gdpr\Service\Anonymize\AnonymizerFactory">
<arguments>
<argument name="anonymizers" xsi:type="array">
Expand Down

0 comments on commit 340d759

Please sign in to comment.