GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BuilderContainer::setDbName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EdmondsCommerce\DoctrineStaticMeta\Builder;
6
7
use EdmondsCommerce\DoctrineStaticMeta\Config;
8
use EdmondsCommerce\DoctrineStaticMeta\Container;
9
use EdmondsCommerce\DoctrineStaticMeta\SimpleEnv;
10
use Exception;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
13
/**
14
 * Class BuilderContainer
15
 *
16
 * @package EdmondsCommerce\DoctrineStaticMeta\Builder
17
 * @SuppressWarnings(PHPMD.Superglobals)
18
 * @SuppressWarnings(PHPMD.StaticAccess)
19
 */
20
class BuilderContainer
21
{
22
23
    public function setEnvFilePath(string $envPath): self
24
    {
25
        SimpleEnv::setEnv($envPath);
26
27
        return $this;
28
    }
29
30
    public function setDbName(string $dbName): self
31
    {
32
        $_SERVER[Config::PARAM_DB_NAME] = $dbName;
33
34
        return $this;
35
    }
36
37
    public function setDbUser(string $dbUser): self
38
    {
39
        $_SERVER[Config::PARAM_DB_USER] = $dbUser;
40
41
        return $this;
42
    }
43
44
    public function setDbPass(string $dbPass): self
45
    {
46
        $_SERVER[Config::PARAM_DB_PASS] = $dbPass;
47
48
        return $this;
49
    }
50
51
    public function setDbHost(string $dbHost): self
52
    {
53
        $_SERVER[Config::PARAM_DB_HOST] = $dbHost;
54
55
        return $this;
56
    }
57
58
    public function setDbConfig(array $config): self
59
    {
60
        foreach ($config as $key => $value) {
61
            $_SERVER[$key] = $value;
62
        }
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return Builder
69
     * @throws Exception
70
     */
71
    public function getBuilder(): Builder
72
    {
73
        /**
74
         * @var Builder
75
         */
76
        $builder = $this->getContainer()->get(Builder::class);
77
78
        return $builder;
79
    }
80
81
    /**
82
     * @return ContainerBuilder
83
     * @SuppressWarnings(PHPMD)
84
     */
85
    public function getContainer(): ContainerBuilder
86
    {
87
        $containerBuilder = new ContainerBuilder();
88
        $containerBuilder->autowire(Builder::class)->setPublic(true);
89
        (new Container())->addConfiguration($containerBuilder, $_SERVER);
90
        $containerBuilder->compile();
91
92
        return $containerBuilder;
93
    }
94
}
95