Table::getColumns()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 9
rs 10
c 1
b 0
f 0
ccs 5
cts 5
cp 1
cc 2
nc 2
nop 0
crap 2
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