HostPortDbTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHost() 0 3 1
A getPort() 0 3 2
A getDb() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Doctrine\Configuration\Driver;
15
16
trait HostPortDbTrait
17
{
18
    protected static string $CFG_HOST = 'ORM_%s_HOST';
19
    protected static string $CFG_PORT = 'ORM_%s_PORT';
20
    protected static string $CFG_DB = 'ORM_%s_DATABASE';
21
22 2
    public function getHost(): ?string
23
    {
24 2
        return $this->get(self::$CFG_HOST, '127.0.0.1', false);
0 ignored issues
show
Bug introduced by
The method get() does not exist on Micro\Plugin\Doctrine\Co...\Driver\HostPortDbTrait. Did you maybe mean getDb()? ( Ignorable by Annotation )

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

24
        return $this->/** @scrutinizer ignore-call */ get(self::$CFG_HOST, '127.0.0.1', false);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
25
    }
26
27 2
    public function getPort(int|null $default = null): ?int
28
    {
29 2
        return (int) $this->get(self::$CFG_PORT, $default) ?: null;
30
    }
31
32 2
    public function getDb(): string
33
    {
34 2
        return $this->get(self::$CFG_DB, null, false);
35
    }
36
}
37