Result   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 60
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRaw() 0 4 1
A getDecoded() 0 4 1
A decode() 0 10 2
1
<?php
2
3
namespace ExiftoolReader;
4
5
/**
6
 * Class Result
7
 */
8
class Result
9
{
10
    /**
11
     * Input data.
12
     *
13
     * @var string
14
     */
15
    private $raw;
16
17
    /**
18
     * Decoded data.
19
     *
20
     * @var array
21
     */
22
    private $decoded = [];
23
24
    /**
25
     * Result constructor.
26
     *
27
     * @param string $raw
28
     */
29
    public function __construct($raw)
30
    {
31
        $this->raw = $raw;
32
        $this->decoded = $this->decode($raw);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getRaw()
39
    {
40
        return $this->raw;
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    public function getDecoded()
47
    {
48
        return $this->decoded;
49
    }
50
51
    /**
52
     * Decode json encoded string.
53
     *
54
     * @param string $raw
55
     * @return array
56
     */
57
    private function decode($raw)
58
    {
59
        $decoded = json_decode($raw, true);
60
61
        if (!empty($decoded[0])) {
62
            return $decoded[0];
63
        }
64
65
        return [];
66
    }
67
}