Passed
Push — master ( f244ed...0973aa )
by Def
13:01 queued 08:48
created

Column::getDefault()   A

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
 * It's a utility that provides a convenient way to create column schema for use with {@see Schema}
12
 * for MSSQL Server.
13
 *
14
 * It provides methods for specifying the properties of a column, such as its type, size, default value, and whether it
15
 * is nullable or not. It also provides a method for creating a column schema based on the specified properties.
16
 *
17
 * For example, the following code creates a column schema for an integer column:
18
 *
19
 * ```php
20
 * $column = (new Column(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
21
 * ```
22
 *
23
 * Provides a fluent interface, which means that the methods can be chained together to create a column schema with
24
 * many properties in a single line of code.
25
 */
26
final class Column extends AbstractColumn
27
{
28
    /**
29
     * @return Expression|string|null The default value of the column
30
     */
31 8
    public function getDefault(): Expression|string|null
32
    {
33 8
        if ($this->default instanceof Expression) {
34 3
            return $this->default;
35
        }
36
37 7
        return $this->buildDefaultValue();
38
    }
39
}
40