Completed
Push — develop ( fa6865...01fb76 )
by Freddie
10:19
created

Column::isForeingKey()   A

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
c 0
b 0
f 0
dl 0
loc 3
rs 10
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
    /**
17
     * @var SchemaAttributeInterface
18
     */
19
    private $schemaAttribute;
20
21 7
    public function __construct(SchemaAttributeInterface $schemaAttribute)
22
    {
23 7
        $this->schemaAttribute = $schemaAttribute;
24 7
    }
25
26 6
    public function getName(): string
27
    {
28 6
        return $this->schemaAttribute->name();
29
    }
30
31 6
    public function getType(): string
32
    {
33 6
        return $this->schemaAttribute->dataType();
34
    }
35
36 6
    public function isPrimaryKey(): bool
37
    {
38 6
        return $this->schemaAttribute->isPk();
39
    }
40
41 6
    public function isForeingKey(): bool
42
    {
43 6
        return $this->schemaAttribute->isFk();
44
    }
45
46 6
    public function getOptions(): array
47
    {
48
        return [
49 6
            'length' => $this->schemaAttribute->maxLength(),
50 6
            'notnull' => $this->schemaAttribute->isRequired(),
51 6
            'autoincrement' => $this->schemaAttribute->isAi(),
52 6
            'comment' => $this->schemaAttribute->name(),
53
            // 'precision' => $this->schemaAttribute->name(),
54
            // 'scale' => $this->schemaAttribute->name(),
55
            // 'unsigned' => $this->schemaAttribute->name(),
56
            // 'fixed' => $this->schemaAttribute->name(),
57
            // 'default' => $this->schemaAttribute->name(),
58
        ];
59
    }
60
}
61