Column::getDefault()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Yiisoft\Db\Expression\Expression;
8
use Yiisoft\Db\Schema\Builder\AbstractColumn;
9
10
/**
11
 * Provides a convenient way to create column schema for use with {@see Schema} for MSSQL Server.
12
 *
13
 * It has methods for specifying the properties of a column, such as its type, size, default value, and whether it
14
 * is nullable or not. It also provides a method for creating a column schema based on the specified properties.
15
 *
16
 * For example, the following code creates a column schema for an integer column:
17
 *
18
 * ```php
19
 * $column = (new Column(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
20
 * ```
21
 *
22
 * Provides a fluent interface, which means that the methods can be chained together to create a column schema with
23
 * many properties in a single line of code.
24
 */
25
final class Column extends AbstractColumn
26
{
27
    /**
28
     * @return Expression|string|null The default value of the column.
29
     */
30 8
    public function getDefault(): Expression|string|null
31
    {
32 8
        if ($this->default instanceof Expression) {
33 3
            return $this->default;
34
        }
35
36 7
        return $this->buildDefaultValue();
37
    }
38
}
39