Table   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 30
rs 10
ccs 12
cts 12
cp 1
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getColumns() 0 9 2
A getOptions() 0 5 1
A __construct() 0 3 1
A getName() 0 3 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of FlexPHP.
4
 *
5
 * (c) Freddie Gar <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace FlexPHP\Database;
11
12
use FlexPHP\Schema\SchemaInterface;
13
14
final class Table implements TableInterface
15
{
16
    private \FlexPHP\Schema\SchemaInterface $schema;
17
18 7
    public function __construct(SchemaInterface $schema)
19
    {
20 7
        $this->schema = $schema;
21 7
    }
22
23 7
    public function getName(): string
24
    {
25 7
        return $this->schema->name();
26
    }
27
28 7
    public function getColumns(): array
29
    {
30 7
        $columns = [];
31
32 7
        foreach ($this->schema->attributes() as $attribute) {
33 7
            $columns[] = new Column($attribute);
34
        }
35
36 7
        return $columns;
37
    }
38
39 7
    public function getOptions(): array
40
    {
41
        return [
42 7
            'charset' => 'utf8mb4',
43
            'collate' => 'utf8mb4_unicode_ci',
44
        ];
45
    }
46
}
47