diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php')
-rw-r--r-- | vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php b/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php new file mode 100644 index 0000000..795f12d --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/PgSQL/ConvertParameters.php | |||
@@ -0,0 +1,49 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\DBAL\Driver\PgSQL; | ||
6 | |||
7 | use Doctrine\DBAL\SQL\Parser\Visitor; | ||
8 | |||
9 | use function count; | ||
10 | use function implode; | ||
11 | |||
12 | final class ConvertParameters implements Visitor | ||
13 | { | ||
14 | /** @var list<string> */ | ||
15 | private array $buffer = []; | ||
16 | |||
17 | /** @var array<array-key, int> */ | ||
18 | private array $parameterMap = []; | ||
19 | |||
20 | public function acceptPositionalParameter(string $sql): void | ||
21 | { | ||
22 | $position = count($this->parameterMap) + 1; | ||
23 | $this->parameterMap[$position] = $position; | ||
24 | $this->buffer[] = '$' . $position; | ||
25 | } | ||
26 | |||
27 | public function acceptNamedParameter(string $sql): void | ||
28 | { | ||
29 | $position = count($this->parameterMap) + 1; | ||
30 | $this->parameterMap[$sql] = $position; | ||
31 | $this->buffer[] = '$' . $position; | ||
32 | } | ||
33 | |||
34 | public function acceptOther(string $sql): void | ||
35 | { | ||
36 | $this->buffer[] = $sql; | ||
37 | } | ||
38 | |||
39 | public function getSQL(): string | ||
40 | { | ||
41 | return implode('', $this->buffer); | ||
42 | } | ||
43 | |||
44 | /** @return array<array-key, int> */ | ||
45 | public function getParameterMap(): array | ||
46 | { | ||
47 | return $this->parameterMap; | ||
48 | } | ||
49 | } | ||