Connection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 2
Metric Value
eloc 6
c 5
b 0
f 2
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A __invoke() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Aura\Sql\ExtendedPdo;
8
use SensitiveParameter;
0 ignored issues
show
Bug introduced by
The type SensitiveParameter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
final class Connection
11
{
12
    private ?ExtendedPdo $pdo = null;
13
14
    /**
15
     * @phpstan-param array<string> $options
16
     * @phpstan-param array<string> $queries
17
     */
18
    public function __construct(
19
        private readonly string $dsn,
20
        private readonly string $username = '',
21
        #[SensitiveParameter]
22
        private readonly string $password = '',
23
        /** @var array<string> */
24
        private readonly array $options = [],
25
        /** @var array<string> */
26
        private readonly array $queries = []
27
    ) {
28
    }
29
30
    public function __invoke(): ExtendedPdo
31
    {
32
        if ($this->pdo instanceof ExtendedPdo) {
33
            return $this->pdo;
34
        }
35
36
        $this->pdo = new ExtendedPdo($this->dsn, $this->username, $this->password, $this->options, $this->queries);
37
38
        return $this->pdo;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->pdo returns the type null which is incompatible with the type-hinted return Aura\Sql\ExtendedPdo.
Loading history...
39
    }
40
}
41