/
DataManipulatorContext.php
98 lines (85 loc) · 2.1 KB
/
DataManipulatorContext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
declare(strict_types=1);
/*
* This file is part of the pseudify database pseudonymizer project
* - (c) 2022 waldhacker UG (haftungsbeschränkt)
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace Waldhacker\Pseudify\Core\Processor\Processing\Pseudonymize;
use Waldhacker\Pseudify\Core\Faker\Faker;
class DataManipulatorContext
{
/**
* @param array<array-key, mixed> $datebaseRow
*
* @internal
*/
public function __construct(
private Faker $faker,
private mixed $rawData,
private mixed $decodedData,
private array $datebaseRow,
private mixed $processedData = null
) {
}
/**
* @api
*/
public function fake(string $scope = Faker::DEFAULT_SCOPE, mixed $source = null): Faker
{
return $this->faker
->withScope($scope)
->withSource($source ? $source : $this->getProcessedData());
}
/**
* @api
*/
public function getRawData(): mixed
{
return $this->rawData;
}
/**
* @api
*/
public function getDecodedData(): mixed
{
return $this->decodedData;
}
/**
* @return array<array-key, mixed>
*
* @api
*/
public function getDatebaseRow(): array
{
return $this->datebaseRow;
}
/**
* @api
*/
public function getProcessedData(): mixed
{
return $this->processedData;
}
/**
* @api
*/
public function setProcessedData(mixed $processedData): DataManipulatorContext
{
$this->processedData = $processedData;
return $this;
}
/**
* @internal
*/
public function withProcessedData(mixed $processedData): DataManipulatorContext
{
return new self($this->faker, $this->rawData, $this->decodedData, $this->datebaseRow, $processedData);
}
}