Column::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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