Derive mode from DSN function

- Add headers in all files
- Minor field name changes
This commit is contained in:
2024-07-20 21:47:21 -04:00
parent 1a37b009ea
commit d8330d828a
81 changed files with 1053 additions and 551 deletions

View File

@@ -1,8 +1,15 @@
<?php declare(strict_types=1);
<?php
/**
* @author Daniel J. Summers <daniel@bitbadger.solutions>
* @license MIT
*/
declare(strict_types=1);
namespace BitBadger\PDODocument\Mapper;
use BitBadger\PDODocument\{Configuration, DocumentException, Mode};
use BitBadger\PDODocument\{Configuration, Mode};
use Exception;
/**
* Map an EXISTS result to a boolean value
@@ -11,14 +18,13 @@ class ExistsMapper implements Mapper
{
/**
* @inheritDoc
* @throws DocumentException If the database mode has not been set
* @throws Exception If the database mode has not been set
*/
public function map(array $result): bool
{
return match (Configuration::$mode) {
return match (Configuration::mode('map existence result')) {
Mode::PgSQL => (bool)$result[0],
Mode::SQLite => (int)$result[0] > 0,
default => throw new DocumentException('Database mode not set; cannot map existence result'),
Mode::SQLite => (int)$result[0] > 0
};
}
}