1 | <?php |
||
29 | abstract class AbstractAnonymizer |
||
30 | { |
||
31 | /** |
||
32 | * Constant to define the type of action for that table |
||
33 | */ |
||
34 | const TRUNCATE_TABLE = 1; |
||
35 | |||
36 | /** |
||
37 | * Constant to define the type of action for that table |
||
38 | */ |
||
39 | const UPDATE_TABLE = 2; |
||
40 | |||
41 | /** |
||
42 | * Contain the configuration object |
||
43 | * |
||
44 | * @var Reader |
||
45 | */ |
||
46 | protected $configuration; |
||
47 | |||
48 | /** |
||
49 | * Configuration of entities |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $configEntites = []; |
||
54 | |||
55 | /** |
||
56 | * Current table (entity) to process |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $entity; |
||
60 | |||
61 | /** |
||
62 | * Current table (entity) Columns |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $entityCols; |
||
66 | |||
67 | |||
68 | /** |
||
69 | * Process the entity according to the anonymizer type |
||
70 | * |
||
71 | * @param string $entity Entity's name |
||
72 | * @param callable|null $callback Callback function with current row num as parameter |
||
73 | * @param bool $pretend Simulate update |
||
74 | * @param bool $returnRes Return queries |
||
75 | */ |
||
76 | abstract public function processEntity( |
||
82 | |||
83 | |||
84 | /** |
||
85 | * Set the configuration |
||
86 | * |
||
87 | * @param Reader $configuration |
||
88 | */ |
||
89 | 17 | public function setConfiguration(Reader $configuration) |
|
94 | |||
95 | |||
96 | /** |
||
97 | * Evaluate, from the configuration if I have to update or Truncate the table |
||
98 | * |
||
99 | * @return int |
||
100 | */ |
||
101 | 14 | protected function whatToDoWithEntity(): int |
|
118 | |||
119 | |||
120 | /** |
||
121 | * Returns the 'delete_where' parameter for an entity in config (or empty) |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | 4 | public function getWhereConditionInConfig(): string |
|
135 | |||
136 | |||
137 | /** |
||
138 | * Generate fake data for an entity and return it as an Array |
||
139 | * |
||
140 | * @return array |
||
141 | */ |
||
142 | 9 | protected function generateFakeData(): array |
|
170 | |||
171 | |||
172 | /** |
||
173 | * Make sure that entity is defined in the configuration |
||
174 | * |
||
175 | * @throws NeuralizerConfigurationException |
||
176 | */ |
||
177 | 14 | private function checkEntityIsInConfig() |
|
190 | |||
191 | /** |
||
192 | * Verify a column is defined in the real entityCols |
||
193 | * @param string $colName |
||
194 | */ |
||
195 | 9 | private function checkColIsInEntity(string $colName) |
|
201 | } |
||
202 |