JsonExporter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of sensorario/resources repository
5
 *
6
 * (c) Simone Gentili <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sensorario\Resources\Helpers;
13
14
use Sensorario\Resources\Interfaces\Helper;
15
use Sensorario\Resources\Resource;
16
17
final class JsonExporter implements Helper
18
{
19
    private $resource;
20
21
    private $json = [];
22
23 1
    public function __construct(Resource $resource)
24
    {
25 1
        $this->resource = $resource;
26 1
    }
27
28 1
    public function execute()
29
    {
30 1
        foreach ($this->resource->properties() as $key => $value) {
31 1
            $this->json[$key] = $value;
32
        }
33
34 1
        return json_encode(
35 1
            $this->json
36
        );
37
    }
38
}
39