JsonExporter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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