Completed
Push — master ( f707f5...a08928 )
by Rasmus
02:27
created

JSONType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
wmc 6
lcom 0
cbo 0
ccs 6
cts 8
cp 0.75
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A convertToSQL() 0 8 3
A convertToPHP() 0 6 3
1
<?php
2
3
namespace mindplay\sql\model\types;
4
5
use mindplay\sql\model\schema\Type;
6
7
class JSONType implements Type
8
{
9 1
    public function convertToSQL($value)
10
    {
11 1
        if ($value === null || $value === '') {
12
            return null;
13
        }
14
15 1
        return json_encode($value);
16
    }
17
18 1
    public function convertToPHP($value)
19
    {
20 1
        return ($value === null || $value === '')
21
            ? null
22 1
            : json_decode($value, true);
23
    }
24
}
25