Passed
Pull Request — master (#14)
by Wilmer
27:48 queued 12:48
created

MssqlColumnSchema::defaultPhpTypecast()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql\Schema;
6
7
use Yiisoft\Db\Schema\ColumnSchema;
8
9
/**
10
 * Class ColumnSchema for MSSQL database
11
 */
12
final class MssqlColumnSchema extends ColumnSchema
13
{
14
    /**
15
     * Prepares default value and converts it according to {@see phpType}.
16
     *
17
     * @param mixed $value default value
18
     *
19
     * @return mixed converted value
20
     */
21
    public function defaultPhpTypecast($value)
22
    {
23
        if ($value !== null) {
24
            // convert from MSSQL column_default format, e.g. ('1') -> 1, ('string') -> string
25
            $value = substr(substr($value, 2), 0, -2);
26
        }
27
28
        return parent::phpTypecast($value);
29
    }
30
}
31