Total Complexity | 5 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class DB extends DBAbstract |
||
8 | { |
||
9 | private $table; |
||
10 | |||
11 | /** |
||
12 | * DB constructor. |
||
13 | * @param string $table |
||
14 | */ |
||
15 | 44 | public function __construct(string $table) |
|
18 | 44 | } |
|
19 | |||
20 | /** |
||
21 | * @param int $modelId |
||
22 | * @param string $column |
||
23 | * @param array $hashes |
||
24 | * @return void |
||
25 | */ |
||
26 | 44 | public function insertHashes(int $modelId, string $column, array $hashes): void |
|
27 | { |
||
28 | 44 | foreach (array_chunk($hashes, 100) as $chunks) { |
|
29 | $insert = array_map(function ($hash) use ($modelId, $column) { |
||
30 | 44 | return "('$modelId', '$column', '$hash')"; |
|
31 | 44 | }, $chunks); |
|
32 | |||
33 | 44 | Query::statement("INSERT INTO $this->table (model_id, name, hash) VALUES ".implode(',', $insert)); |
|
34 | } |
||
35 | 44 | } |
|
36 | |||
37 | /** |
||
38 | * @param int $modelId |
||
39 | * @param string $column |
||
40 | * @return void |
||
41 | */ |
||
42 | 44 | public function deleteHashes(int $modelId, string $column): void |
|
45 | 44 | } |
|
46 | |||
47 | /** |
||
48 | * @param string $column |
||
49 | * @param string $hash |
||
50 | * @return array |
||
51 | */ |
||
52 | 24 | public function findByHash(string $column, string $hash): array |
|
66 |