42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
// NullDbBackend.php
|
|
// Created: 2021-05-02
|
|
// Updated: 2024-04-10
|
|
|
|
namespace Index\Data\NullDb;
|
|
|
|
use Index\Data\IDbBackend;
|
|
use Index\Data\IDbConnection;
|
|
use Index\Data\IDbConnectionInfo;
|
|
|
|
/**
|
|
* Information about the dummy database layer.
|
|
*/
|
|
class NullDbBackend implements IDbBackend {
|
|
public function isAvailable(): bool {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Creates a dummy database connection.
|
|
*
|
|
* @param NullDbConnectionInfo $connectionInfo Dummy connection info.
|
|
* @return NullDbConnection Dummy connection instance.
|
|
*/
|
|
public function createConnection(IDbConnectionInfo $connectionInfo): IDbConnection {
|
|
return new NullDbConnection;
|
|
}
|
|
|
|
/**
|
|
* Constructs a connection info instance from a dsn.
|
|
*
|
|
* NullDb has no parameters that can be controlled using the DSN.
|
|
*
|
|
* @param string|array $dsn DSN with connection information.
|
|
* @return NullDbConnectionInfo Dummy connection info instance.
|
|
*/
|
|
public function parseDsn(string|array $dsn): IDbConnectionInfo {
|
|
return new NullDbConnectionInfo;
|
|
}
|
|
}
|