SQLServerDriverConfig   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 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\Config\SQLServer\ConnectionConfig;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Cycle\Database\Config\ConnectionConfig. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
15
use Cycle\Database\Driver\SQLServer\SQLServerDriver;
16
17
/**
18
 * @template-extends DriverConfig<ConnectionConfig>
19
 */
20
class SQLServerDriverConfig extends DriverConfig
21
{
22
    public function __construct(
23
        ConnectionConfig $connection,
24
        string $driver = SQLServerDriver::class,
25
        bool $reconnect = true,
26
        string $timezone = 'UTC',
27
        bool $queryCache = true,
28
        bool $readonlySchema = false,
29
        bool $readonly = false,
30
        array $options = [],
31
    ) {
32
        /** @psalm-suppress ArgumentTypeCoercion */
33
        parent::__construct(
34
            connection: $connection,
35
            driver: $driver,
36
            reconnect: $reconnect,
37
            timezone: $timezone,
38
            queryCache: $queryCache,
39
            readonlySchema: $readonlySchema,
40
            readonly: $readonly,
41
            options: $options,
42
        );
43
    }
44
}
45