Column   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 37
rs 10
ccs 17
cts 17
cp 1
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isForeingKey() 0 3 1
A getOptions() 0 8 1
A getName() 0 3 1
A __construct() 0 3 1
A isPrimaryKey() 0 3 1
A getType() 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\SchemaAttributeInterface;
13
14
final class Column implements ColumnInterface
15
{
16
    private \FlexPHP\Schema\SchemaAttributeInterface $schemaAttribute;
17
18 17
    public function __construct(SchemaAttributeInterface $schemaAttribute)
19
    {
20 17
        $this->schemaAttribute = $schemaAttribute;
21 17
    }
22
23 16
    public function getName(): string
24
    {
25 16
        return $this->schemaAttribute->name();
26
    }
27
28 16
    public function getType(): string
29
    {
30 16
        return $this->schemaAttribute->dataType();
31
    }
32
33 9
    public function isPrimaryKey(): bool
34
    {
35 9
        return $this->schemaAttribute->isPk();
36
    }
37
38 9
    public function isForeingKey(): bool
39
    {
40 9
        return $this->schemaAttribute->isFk();
41
    }
42
43 16
    public function getOptions(): array
44
    {
45
        return [
46 16
            'length' => $this->schemaAttribute->maxLength(),
47 16
            'notnull' => $this->schemaAttribute->isRequired(),
48 16
            'autoincrement' => $this->schemaAttribute->isAi(),
49 16
            'comment' => $this->schemaAttribute->name(),
50 16
            'default' => $this->schemaAttribute->default(),
51
            // 'precision' => $this->schemaAttribute->name(),
52
            // 'scale' => $this->schemaAttribute->name(),
53
            // 'unsigned' => $this->schemaAttribute->name(),
54
            // 'fixed' => $this->schemaAttribute->name(),
55
        ];
56
    }
57
}
58