Passed
Pull Request — master (#14)
by Wilmer
25:49 queued 10:47
created

MssqlColumnSchema   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A defaultPhpTypecast() 0 8 2
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