Passed
Pull Request — 2.x (#83)
by Maxim
36:42 queued 16:48
created

FileConnectionConfig::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Cycle Database package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Database\Config\SQLite;
13
14
use Cycle\Database\Config\ProvidesSourceString;
15
16
class FileConnectionConfig extends ConnectionConfig implements ProvidesSourceString
17
{
18
    /**
19
     * @param string $database The pathname to the SQLite database file.
20
     *        - In case of keyword ":memory:" {@see MemoryConnectionConfig}.
21
     *        - In case of empty string value {@see TempFileConnectionConfig}.
22
     * @param array $options
23
     */
24 26
    public function __construct(
25
        public string $database = '',
26
        array $options = []
27
    ) {
28 26
        parent::__construct($options);
29 26
    }
30
31
    /**
32
     * Returns the SQLite-specific PDO DataSourceName, that looks like:
33
     * <code>
34
     *  sqlite:/path/to/database.db
35
     * </code>
36
     *
37
     * {@inheritDoc}
38
     */
39 8
    public function getDsn(): string
40
    {
41 8
        return \sprintf('%s:%s', $this->getName(), $this->database);
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 2
    public function getSourceString(): string
48
    {
49 2
        return $this->database;
50
    }
51
52
    public static function __set_state(array $state): self
53
    {
54
        return new self(...$state);
0 ignored issues
show
Bug introduced by
$state is expanded, but the parameter $database of Cycle\Database\Config\SQ...onConfig::__construct() does not expect variable arguments. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

54
        return new self(/** @scrutinizer ignore-type */ ...$state);
Loading history...
55
    }
56
}
57