Initial SQLite development (#1)

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2024-06-08 23:58:45 +00:00
parent e91acee70f
commit f784f3e52c
66 changed files with 5509 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
<?php declare(strict_types=1);
namespace BitBadger\PDODocument\Mapper;
use BitBadger\PDODocument\{Configuration, DocumentException, Mode};
/**
* Map an EXISTS result to a boolean value
*/
class ExistsMapper implements Mapper
{
/**
* @inheritDoc
* @throws DocumentException If the database mode has not been set
*/
public function map(array $result): bool
{
return match (Configuration::$mode) {
Mode::PgSQL => (bool)$result[0],
Mode::SQLite => (int)$result[0] > 0,
default => throw new DocumentException('Database mode not set; cannot map existence result'),
};
}
}