1 | <?php |
||
29 | abstract class AbstractAnonymizer |
||
30 | { |
||
31 | /** |
||
32 | * Truncate table |
||
33 | */ |
||
34 | const TRUNCATE_TABLE = 1; |
||
35 | |||
36 | /** |
||
37 | * Update data into table |
||
38 | */ |
||
39 | const UPDATE_TABLE = 2; |
||
40 | |||
41 | /** |
||
42 | * Insert data into table |
||
43 | */ |
||
44 | const INSERT_TABLE = 4; |
||
45 | |||
46 | |||
47 | /** |
||
48 | * Contains the configuration object |
||
49 | * |
||
50 | * @var Reader |
||
51 | */ |
||
52 | protected $configuration; |
||
53 | |||
54 | /** |
||
55 | * Configuration of entities |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $configEntites = []; |
||
60 | |||
61 | /** |
||
62 | * Current table (entity) to process |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | protected $entity; |
||
67 | |||
68 | /** |
||
69 | * Current table (entity) Columns |
||
70 | * |
||
71 | * @var array |
||
72 | */ |
||
73 | protected $entityCols; |
||
74 | |||
75 | |||
76 | /** |
||
77 | * Process the entity according to the anonymizer type |
||
78 | * |
||
79 | * @param string $entity Entity's name |
||
80 | * @param callable|null $callback Callback function with current row num as parameter |
||
81 | * @param bool $pretend Simulate update |
||
82 | * @param bool $returnRes Return queries |
||
83 | */ |
||
84 | abstract public function processEntity( |
||
90 | |||
91 | |||
92 | /** |
||
93 | * Set the configuration |
||
94 | * |
||
95 | * @param Reader $configuration |
||
96 | */ |
||
97 | 20 | public function setConfiguration(Reader $configuration): void |
|
102 | |||
103 | |||
104 | /** |
||
105 | * Evaluate, from the configuration if I have to update or Truncate the table |
||
106 | * |
||
107 | * @return int |
||
108 | */ |
||
109 | 16 | protected function whatToDoWithEntity(): int |
|
133 | |||
134 | |||
135 | /** |
||
136 | * Returns the 'delete_where' parameter for an entity in config (or empty) |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 4 | public function getWhereConditionInConfig(): string |
|
150 | |||
151 | |||
152 | /** |
||
153 | * Generate fake data for an entity and return it as an Array |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | 12 | protected function generateFakeData(): array |
|
188 | |||
189 | |||
190 | /** |
||
191 | * Make sure that entity is defined in the configuration |
||
192 | * |
||
193 | * @throws NeuralizerConfigurationException |
||
194 | */ |
||
195 | 16 | private function checkEntityIsInConfig(): void |
|
208 | |||
209 | /** |
||
210 | * Verify a column is defined in the real entityCols |
||
211 | * |
||
212 | * @throws NeuralizerConfigurationException |
||
213 | * @param string $colName [description] |
||
214 | */ |
||
215 | 12 | private function checkColIsInEntity(string $colName): void |
|
221 | } |
||
222 |