NamedExtendedPdoProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A setContext() 0 4 1
A get() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\AuraSqlModule;
6
7
use Aura\Sql\ExtendedPdo;
8
use Override;
9
use Ray\Di\InjectorInterface;
10
use Ray\Di\ProviderInterface;
11
use Ray\Di\SetContextInterface;
12
13
/** @implements ProviderInterface<ExtendedPdo> */
14
15
final class NamedExtendedPdoProvider implements ProviderInterface, SetContextInterface
16
{
17
    private string $context;
18
19
    /**
20
     * {@inheritDoc}
21
     */
22
    #[Override]
23
    public function setContext($context)
24
    {
25
        $this->context = $context;
26
    }
27
28
    public function __construct(private readonly InjectorInterface $injector)
29
    {
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    #[Override]
36
    public function get(): ExtendedPdo
37
    {
38
        $connection = $this->injector->getInstance(EnvConnection::class, $this->context);
39
40
        return ($connection)();
41
    }
42
}
43