Completed
Push — 2.1 ( 481970...56545c )
by
unknown
11:50
created

ColumnSchema   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A dbTypecast() 0 12 4
A phpTypecast() 0 12 4
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\mysql;
9
10
use yii\db\ExpressionInterface;
11
use yii\db\JsonExpression;
12
13
/**
14
 * Class ColumnSchema for MySQL database
15
 *
16
 * @author Dmytro Naumenko <[email protected]>
17
 * @since 2.0.14.1
18
 */
19
class ColumnSchema extends \yii\db\ColumnSchema
20
{
21
    /**
22
     * @var bool whether the column schema should OMIT using JSON support feature.
23
     * You can use this property to make upgrade to Yii 2.0.14 easier.
24
     * Default to `false`, meaning JSON support is enabled.
25
     *
26
     * @since 2.0.14.1
27
     * @deprecated Since 2.0.14.1 and will be removed in 2.1.
28
     */
29
    public $disableJsonSupport = false;
30
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 210
    public function dbTypecast($value)
36
    {
37 210
        if ($value instanceof ExpressionInterface) {
38 24
            return $value;
39
        }
40
41 207
        if (!$this->disableJsonSupport && $this->dbType === Schema::TYPE_JSON) {
0 ignored issues
show
Deprecated Code introduced by
The property yii\db\mysql\ColumnSchema::$disableJsonSupport has been deprecated with message: Since 2.0.14.1 and will be removed in 2.1.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
42 1
            return new JsonExpression($value, $this->type);
43
        }
44
45 206
        return $this->typecast($value);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 328
    public function phpTypecast($value)
52
    {
53 328
        if ($value === null) {
54 326
            return null;
55
        }
56
57 176
        if (!$this->disableJsonSupport && $this->type === Schema::TYPE_JSON) {
0 ignored issues
show
Deprecated Code introduced by
The property yii\db\mysql\ColumnSchema::$disableJsonSupport has been deprecated with message: Since 2.0.14.1 and will be removed in 2.1.

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
58 1
            return json_decode($value, true);
59
        }
60
61 176
        return parent::phpTypecast($value);
62
    }
63
}
64