Passed
Pull Request — master (#19371)
by Wilmer
19:12
created

ColumnSchema::defaultPhpTypecast()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 8
ccs 0
cts 6
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\mssql;
9
10
/**
11
 * Class ColumnSchema for MSSQL database
12
 *
13
 * @since 2.0.23
14
 */
15
class ColumnSchema extends \yii\db\ColumnSchema
16
{
17
    /**
18
     * @var bool whether this column is a computed column
19
     * @since 2.0.39
20
     */
21
    public $isComputed;
22
23
24
    /**
25
     * Prepares default value and converts it according to [[phpType]]
26
     * @param mixed $value default value
27
     * @return mixed converted value
28
     * @since 2.0.24
29
     */
30
    public function defaultPhpTypecast($value)
31
    {
32
        if ($value !== null) {
33
            // convert from MSSQL column_default format, e.g. ('1') -> 1, ('string') -> string
34
            $value = substr(substr($value, 2), 0, -2);
35
        }
36
37
        return parent::phpTypecast($value);
38
    }
39
}
40