Completed
Push — master ( 9988ef...c2eae6 )
by Alexander
20:29
created

ColumnSchema::phpTypecast()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 10
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
     * Prepares default value and converts it according to [[phpType]]
19
     * @param mixed $value default value
20
     * @return mixed converted value
21
     * @since 2.0.24
22
     */
23 231
    public function defaultPhpTypecast($value)
24
    {
25 231
        if ($value !== null) {
26
            // convert from MSSQL column_default format, e.g. ('1') -> 1, ('string') -> string
27 140
            $value = substr(substr($value, 2), 0, -2);
28
        }
29
30 231
        return parent::phpTypecast($value);
31
    }
32
}
33