DmsDatabase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 4 1
A getPhpName() 0 8 1
A getDmsTables() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Dms\MySQL\Generator\Dms;
4
5
use Janisbiz\LightOrm\Generator\Dms\DmsDatabaseInterface;
6
use Janisbiz\LightOrm\Generator\Dms\DmsTableInterface;
7
8
class DmsDatabase implements DmsDatabaseInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $name;
14
15
    /**
16
     * @var DmsTableInterface[]
17
     */
18
    protected $dmsTables = [];
19
20
    /**
21
     * @param string $name
22
     * @param DmsTableInterface[] $dmsTables
23
     */
24
    public function __construct(string $name, array $dmsTables)
25
    {
26
        $this->name = $name;
27
        $this->dmsTables = $dmsTables;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getPhpName(): string
42
    {
43
        return \ucfirst(\preg_replace_callback(
44
            '/[^a-z0-9]+(?<name>\w{1})/i',
45
            function ($matches) {
46
                return \strtoupper($matches['name']);
47
            },
48
            $this->getName()
49
        ));
50
    }
51
52
    /**
53
     * @return DmsTableInterface[]
54
     */
55
    public function getDmsTables(): array
56
    {
57
        return $this->dmsTables;
58
    }
59
}
60