Passed
Push — dbal ( a67a72...c31592 )
by Greg
08:19
created

AbstractColumn::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2022 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\DB\Schema;
21
22
use Fisharebest\Webtrees\DB\Expression;
23
24
/**
25
 * Common methods for all column types.
26
 */
27
abstract class AbstractColumn
28
{
29
    public string $comment = '';
30
31
    public int|string|Expression|null $default = null;
32
33
    public bool $nullable = false;
34
35
    public bool $invisible = false;
36
37
    /**
38
     * @param string $name
39
     */
40
    public function __construct(private readonly string $name)
41
    {
42
    }
43
44
    /**
45
     * @param string $comment
46
     *
47
     * @return $this
48
     */
49
    public function comment(string $comment): static
50
    {
51
        $this->comment = $comment;
52
53
        return $this;
54
    }
55
56
    /**
57
     * @param int|float|string|Expression|null $default
58
     *
59
     * @return $this
60
     */
61
    public function default(int|float|string|Expression|null $default): static
62
    {
63
        $this->default = $default;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @param bool $nullable
70
     *
71
     * @return $this
72
     */
73
    public function nullable(bool $nullable = true): static
74
    {
75
        $this->nullable = $nullable;
76
77
        return $this;
78
    }
79
80
    /**
81
     * @param bool $invisible
82
     *
83
     * @return $this
84
     */
85
    public function invisible(bool $invisible = true): static
86
    {
87
        $this->invisible = $invisible;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getComment(): string
96
    {
97
        return $this->comment;
98
    }
99
100
    /**
101
     * @return int|string|Expression|null
102
     */
103
    public function getDefault(): int|string|Expression|null
104
    {
105
        return $this->default;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getName(): string
112
    {
113
        return $this->name;
114
    }
115
116
    /**
117
     * @return bool
118
     */
119
    public function isInvisible(): bool
120
    {
121
        return $this->invisible;
122
    }
123
124
    /**
125
     * @return bool
126
     */
127
    public function isNullable(): bool
128
    {
129
        return $this->nullable;
130
    }
131
}
132