Completed
Push — master ( d8757f...fa9ad1 )
by Matteo
02:59
created

JsonEncoder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 17
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 4 1
A decode() 0 4 1
A getExtension() 0 4 1
1
<?php
2
3
namespace Mattbit\Flat\Storage;
4
5
use Mattbit\Flat\Document\Document;
6
use Mattbit\Flat\Document\Encodable;
7
8
class JsonEncoder implements EncoderInterface
9
{
10 1
    public function encode(Encodable $document)
11
    {
12 1
        return json_encode($document->toArray());
13
    }
14
15 1
    public function decode($data)
16
    {
17 1
        return new Document(json_decode($data, true));
18
    }
19
20 1
    public function getExtension()
21
    {
22 1
        return 'json';
23
    }
24
}
25