Completed
Push — master ( 059a7f...25fd12 )
by Oscar
02:16
created

Json   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getExtension() 0 4 1
A stringify() 0 4 1
A parse() 0 4 1
1
<?php
2
3
namespace FlyCrud\Formats;
4
5
use FlyCrud\FormatInterface;
6
7
class Json implements FormatInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function getExtension()
13
    {
14
        return 'json';
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function stringify(array $data)
21
    {
22
        return json_encode($data, JSON_PRETTY_PRINT);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function parse($source)
29
    {
30
        return json_decode($source, true);
31
    }
32
}
33