-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.php
More file actions
37 lines (29 loc) · 1020 Bytes
/
Database.php
File metadata and controls
37 lines (29 loc) · 1020 Bytes
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
<?php
namespace FpDbTest;
use FpDbTest\Placeholder\PlaceholderReplacer;
use FpDbTest\Placeholder\Skip;
use FpDbTest\QueryTemplate\QueryTemplateProcessor;
final readonly class Database implements DatabaseInterface
{
// private mysqli $mysqli;
private PlaceholderReplacer $placeholderReplacer;
public function __construct()
{
// $this->mysqli = $mysqli;
$this->placeholderReplacer = PlaceholderReplacer::create();
}
public function buildQuery(string $query, array $args = []): string
{
$queryBuilderAssistant = new QueryTemplateProcessor(
allowedPlaceholders: PlaceholderReplacer::ALLOWED_TAGS,
placeholderCallback: function (mixed $value, string $placeholderTag = null): string {
return $this->placeholderReplacer->format($value, $placeholderTag);
}
);
return $queryBuilderAssistant->processQueryTemplate($query, $args);
}
public function skip()
{
return new Skip();
}
}