Update option/result library
- Restore getOrThrow() calls
This commit is contained in:
parent
039283224a
commit
9e0e663811
6
composer.lock
generated
6
composer.lock
generated
|
@ -8,11 +8,11 @@
|
|||
"packages": [
|
||||
{
|
||||
"name": "bit-badger/inspired-by-fsharp",
|
||||
"version": "v1.0.0-beta1",
|
||||
"version": "v1.0.0-beta2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp",
|
||||
"reference": "efb3a4461edcb23e0dd82068adeb0591240870b0"
|
||||
"reference": "fad428a4e40b606987499b17bb2d5b7d4b04502d"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.2"
|
||||
|
@ -49,7 +49,7 @@
|
|||
"rss": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp.rss",
|
||||
"source": "https://git.bitbadger.solutions/bit-badger/inspired-by-fsharp"
|
||||
},
|
||||
"time": "2024-07-28T21:35:11+00:00"
|
||||
"time": "2024-07-29T17:58:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "netresearch/jsonmapper",
|
||||
|
|
|
@ -66,15 +66,14 @@ class Configuration
|
|||
* Retrieve a new connection to the database
|
||||
*
|
||||
* @return PDO A new connection to the SQLite database with foreign key support enabled
|
||||
* @throws DocumentException If this is called before a connection string is set
|
||||
* @throws Exception If this is called before a connection string is set
|
||||
*/
|
||||
public static function dbConn(): PDO
|
||||
{
|
||||
if (is_null(self::$pdo)) {
|
||||
if (self::$pdoDSN->isNone()) {
|
||||
throw new DocumentException('Please provide a data source name (DSN) before attempting data access');
|
||||
}
|
||||
self::$pdo = new PDO(self::$pdoDSN->get(), $_ENV['PDO_DOC_USERNAME'] ?? self::$username,
|
||||
$dsn = self::$pdoDSN->getOrThrow(fn()
|
||||
=> new DocumentException('Please provide a data source name (DSN) before attempting data access'));
|
||||
self::$pdo = new PDO($dsn, $_ENV['PDO_DOC_USERNAME'] ?? self::$username,
|
||||
$_ENV['PDO_DOC_PASSWORD'] ?? self::$password, self::$options);
|
||||
}
|
||||
|
||||
|
@ -89,10 +88,8 @@ class Configuration
|
|||
*/
|
||||
public static function mode(?string $process = null): Mode
|
||||
{
|
||||
if (self::$mode->isNone()) {
|
||||
throw new DocumentException('Database mode not set' . (is_null($process) ? '' : "; cannot $process"));
|
||||
}
|
||||
return self::$mode->get();
|
||||
return self::$mode->getOrThrow(fn()
|
||||
=> new DocumentException('Database mode not set' . (is_null($process) ? '' : "; cannot $process")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user