Derive mode from DSN function
- Add headers in all files - Minor field name changes
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument\Mapper;
|
||||
|
||||
@@ -7,9 +13,7 @@ namespace BitBadger\PDODocument\Mapper;
|
||||
*/
|
||||
class ArrayMapper implements Mapper
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function map(array $result): array
|
||||
{
|
||||
return $result;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument\Mapper;
|
||||
|
||||
@@ -7,9 +13,7 @@ namespace BitBadger\PDODocument\Mapper;
|
||||
*/
|
||||
class CountMapper implements Mapper
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
/** @inheritDoc */
|
||||
public function map(array $result): int
|
||||
{
|
||||
return (int) $result[0];
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument\Mapper;
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?php
|
||||
/**
|
||||
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BitBadger\PDODocument\Mapper;
|
||||
|
||||
|
||||
@@ -1,9 +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;
|
||||
|
||||
/**
|
||||
* Map a string result from the
|
||||
* Map a string result from the named field
|
||||
*
|
||||
* @implements Mapper<string>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user