Skip to content

Commit 44e6a6d

Browse files
committed
remove unused argument entity
1 parent 6ebcc0d commit 44e6a6d

File tree

9 files changed

+20
-62
lines changed

9 files changed

+20
-62
lines changed

Model/Entity/EntityValue/CustomAttributesProcessor.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,12 @@ public function __construct(
2424
$this->processor = $processor;
2525
}
2626

27-
public function process(object $entity, string $key, $values): void
27+
public function process(string $key, $values): void
2828
{
29-
if ($this->isValid($entity, $key, $values)) {
29+
if ($key === CustomAttributesDataInterface::CUSTOM_ATTRIBUTES && is_iterable($values)) {
3030
foreach ($values as $value) {
31-
$this->processor->process($entity, $key, $value);
31+
$this->processor->process($key, $value);
3232
}
3333
}
3434
}
35-
36-
/**
37-
* Check whether the entity object and the value key are valid
38-
*
39-
* @param object $entity
40-
* @param string $key
41-
* @param mixed $values
42-
* @return bool
43-
*/
44-
private function isValid(object $entity, string $key, $values): bool
45-
{
46-
return $entity instanceof CustomAttributesDataInterface &&
47-
$key === CustomAttributesDataInterface::CUSTOM_ATTRIBUTES &&
48-
is_iterable($values);
49-
}
5035
}

Model/Entity/EntityValue/ExtensibleDataProcessor.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,12 @@ public function __construct(
2424
$this->processor = $processor;
2525
}
2626

27-
public function process(object $entity, string $key, $values): void
27+
public function process(string $key, $values): void
2828
{
29-
if ($this->isValid($entity, $key, $values)) {
29+
if ($key === ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY && is_iterable($values)) {
3030
foreach ($values as $value) {
31-
$this->processor->process($entity, $key, $value);
31+
$this->processor->process($key, $value);
3232
}
3333
}
3434
}
35-
36-
/**
37-
* Check whether the entity object and the value key are valid
38-
*
39-
* @param object $entity
40-
* @param string $key
41-
* @param mixed $values
42-
* @return bool
43-
*/
44-
private function isValid(object $entity, string $key, $values): bool
45-
{
46-
return $entity instanceof ExtensibleDataInterface &&
47-
$key === ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY &&
48-
is_iterable($values);
49-
}
5035
}

Model/Entity/EntityValue/StrategyProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function __construct(
2222
$this->processors = $processors;
2323
}
2424

25-
public function process(object $entity, string $key, $value): void
25+
public function process(string $key, $value): void
2626
{
27-
($this->processors[$key] ?? $this->processors['default'])->process($entity, $key, $value);
27+
($this->processors[$key] ?? $this->processors['default'])->process($key, $value);
2828
}
2929
}

Model/Entity/EntityValueProcessorInterface.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,5 @@
1212
*/
1313
interface EntityValueProcessorInterface
1414
{
15-
/**
16-
* @param object $entity
17-
* @param string $key
18-
* @param mixed $value
19-
* @return void
20-
*/
21-
public function process(object $entity, string $key, $value): void;
15+
public function process(string $key, $value): void;
2216
}

Service/Anonymize/AnonymizerFactory.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313

1414
final class AnonymizerFactory
1515
{
16-
/**
17-
* Constants for the anonymizer key codes
18-
*/
19-
public const DEFAULT_ANONYMIZER = 'default';
16+
public const DEFAULT_KEY = 'default';
2017

2118
/**
2219
* @var string[]

Service/Anonymize/Processor/Entity/EntityValue/Processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
$this->anonymizer = $anonymizer;
4141
}
4242

43-
public function process(object $entity, string $key, $value): void
43+
public function process(string $key, $value): void
4444
{
4545
if (in_array($key, $this->metadata->getAttributes(), true)) {
4646
$this->document->addData($key, $this->anonymizer->anonymize($value));

Service/Anonymize/Processor/Entity/EntityValue/SmartProcessor.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Opengento\Gdpr\Model\Entity\DocumentInterface;
1111
use Opengento\Gdpr\Model\Entity\EntityValueProcessorInterface;
1212
use Opengento\Gdpr\Service\Anonymize\AnonymizerFactory;
13-
use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface;
1413
use Opengento\Gdpr\Service\Anonymize\MetadataInterface;
1514
use function in_array;
1615

@@ -41,17 +40,15 @@ public function __construct(
4140
$this->anonymizerFactory = $anonymizerFactory;
4241
}
4342

44-
public function process(object $entity, string $key, $value): void
43+
public function process(string $key, $value): void
4544
{
4645
if (in_array($key, $this->metadata->getAttributes(), true)) {
47-
$this->document->addData($key, $this->resolveAnonymizer($key)->anonymize($value));
46+
$this->document->addData(
47+
$key,
48+
$this->anonymizerFactory->get(
49+
$this->metadata->getAnonymizerStrategiesByAttributes()[$key] ?? AnonymizerFactory::DEFAULT_KEY
50+
)->anonymize($value)
51+
);
4852
}
4953
}
50-
51-
private function resolveAnonymizer(string $key): AnonymizerInterface
52-
{
53-
return $this->anonymizerFactory->get(
54-
$this->metadata->getAnonymizerStrategiesByAttributes()[$key] ?? AnonymizerFactory::DEFAULT_ANONYMIZER
55-
);
56-
}
5754
}

Service/Export/Processor/Entity/EntityValue/DataProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
$this->metadata = $metadata;
3333
}
3434

35-
public function process(object $entity, string $key, $value): void
35+
public function process(string $key, $value): void
3636
{
3737
if (in_array($key, $this->metadata->getAttributes(), true)) {
3838
$this->document->addData($key, $value);

Service/Export/Processor/Entity/EntityValue/EntityProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(
4040
$this->dataCollector = $dataCollector;
4141
}
4242

43-
public function process(object $entity, string $key, $value): void
43+
public function process(string $key, $value): void
4444
{
4545
if (in_array($key, $this->metadata->getAttributes(), true)) {
4646
$this->document->addData($key, $this->dataCollector->collect($value));

0 commit comments

Comments
 (0)