Passed
Push — 2.x ( d27db5...1d7bfe )
by Aleksei
21:55 queued 01:54
created

DriverConfig   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 26
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __set_state() 0 3 1
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;
13
14
use Cycle\Database\Driver\DriverInterface;
15
16
/**
17
 * Connection configuration described in DBAL config file. Any driver can be
18
 * used as data source for multiple databases as table prefix and quotation
19
 * defined on Database instance level.
20
 *
21
 * @template T of PDOConnectionConfig
22
 */
23
abstract class DriverConfig
24
{
25
    /**
26
     * @param T $connection
27
     * @param class-string<DriverInterface> $driver
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<DriverInterface> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<DriverInterface>.
Loading history...
28
     * @param bool $reconnect Allow reconnects
29
     * @param non-empty-string $timezone All datetime objects will be converted
30
     *        relative to this timezone (must match with DB timezone!)
31
     * @param bool $queryCache Enables query caching
32
     * @param bool $readonlySchema Disable schema modifications
33
     * @param bool $readonly Disable write expressions
34
     */
35 60
    public function __construct(
36
        public ConnectionConfig $connection,
37
        public string $driver,
38
        public bool $reconnect = true,
39
        public string $timezone = 'UTC',
40
        public bool $queryCache = true,
41
        public bool $readonlySchema = false,
42
        public bool $readonly = false,
43
    ) {
44 60
    }
45
46
    public static function __set_state(array $properties): static
47
    {
48
        return new static(...$properties);
49
    }
50
}
51