-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathFileConnectionConfig.php
More file actions
52 lines (44 loc) · 1.3 KB
/
FileConnectionConfig.php
File metadata and controls
52 lines (44 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* This file is part of Cycle Database package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Cycle\Database\Config\SQLite;
use Cycle\Database\Config\ProvidesSourceString;
class FileConnectionConfig extends ConnectionConfig implements ProvidesSourceString
{
/**
* @param string $database The pathname to the SQLite database file.
* - In case of keyword ":memory:" {@see MemoryConnectionConfig}.
* - In case of empty string value {@see TempFileConnectionConfig}.
*/
public function __construct(
public string $database = '',
array $options = [],
) {
parent::__construct($options);
}
/**
* Returns the SQLite-specific PDO DataSourceName, that looks like:
* <code>
* sqlite:/path/to/database.db
* </code>
*
* {@inheritDoc}
*/
public function getDsn(): string
{
return \sprintf('%s:%s', $this->getName(), $this->database);
}
public function getSourceString(): string
{
return $this->database;
}
public function formatExceptionMessage(string $message): string
{
return \sprintf('(%s) %s', $this->database, $message);
}
}