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

Column   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 12
c 1
b 0
f 0
dl 0
loc 39
rs 10
ccs 16
cts 16
cp 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A __construct() 0 3 1
A getType() 0 3 1
A isForeingKey() 0 3 1
A getOptions() 0 7 1
A isPrimaryKey() 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
    /**
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