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 | * Contain the configuration object |
||
48 | * |
||
49 | * @var Reader |
||
50 | */ |
||
51 | protected $configuration; |
||
52 | |||
53 | /** |
||
54 | * Configuration of entities |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $configEntites = []; |
||
59 | |||
60 | /** |
||
61 | * Current table (entity) to process |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $entity; |
||
65 | |||
66 | /** |
||
67 | * Current table (entity) Columns |
||
68 | * @var array |
||
69 | */ |
||
70 | protected $entityCols; |
||
71 | |||
72 | |||
73 | /** |
||
74 | * Process the entity according to the anonymizer type |
||
75 | * |
||
76 | * @param string $entity Entity's name |
||
77 | * @param callable|null $callback Callback function with current row num as parameter |
||
78 | * @param bool $pretend Simulate update |
||
79 | * @param bool $returnRes Return queries |
||
80 | */ |
||
81 | abstract public function processEntity( |
||
87 | |||
88 | |||
89 | /** |
||
90 | * Set the configuration |
||
91 | * |
||
92 | * @param Reader $configuration |
||
93 | */ |
||
94 | 17 | public function setConfiguration(Reader $configuration) |
|
99 | |||
100 | |||
101 | /** |
||
102 | * Evaluate, from the configuration if I have to update or Truncate the table |
||
103 | * |
||
104 | * @return int |
||
105 | */ |
||
106 | 13 | protected function whatToDoWithEntity(): int |
|
130 | |||
131 | |||
132 | /** |
||
133 | * Returns the 'delete_where' parameter for an entity in config (or empty) |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 4 | public function getWhereConditionInConfig(): string |
|
147 | |||
148 | |||
149 | /** |
||
150 | * Generate fake data for an entity and return it as an Array |
||
151 | * |
||
152 | * @return array |
||
153 | */ |
||
154 | 9 | protected function generateFakeData(): array |
|
185 | |||
186 | |||
187 | /** |
||
188 | * Make sure that entity is defined in the configuration |
||
189 | * |
||
190 | * @throws NeuralizerConfigurationException |
||
191 | */ |
||
192 | 13 | private function checkEntityIsInConfig() |
|
205 | |||
206 | /** |
||
207 | * Verify a column is defined in the real entityCols |
||
208 | * @param string $colName |
||
209 | */ |
||
210 | 9 | private function checkColIsInEntity(string $colName) |
|
216 | } |
||
217 |