JsonInspector   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 46
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A readJsonNodeValue() 0 7 1
A searchJsonPath() 0 4 1
A validateJson() 0 7 1
A readJson() 0 4 1
A writeJson() 0 4 1
1
<?php
2
3
namespace Rezzza\RestApiBehatExtension\Json;
4
5
use JsonSchema\Validator;
6
use Symfony\Component\PropertyAccess\PropertyAccess;
7
8
class JsonInspector
9
{
10
    private $jsonParser;
11
12
    private $jsonStorage;
13
14
    private $jsonSearcher;
15
16
    public function __construct(JsonStorage $jsonStorage, JsonParser $jsonParser, JsonSearcher $jsonSearcher)
17
    {
18
        $this->jsonParser = $jsonParser;
19
        $this->jsonStorage = $jsonStorage;
20
        $this->jsonSearcher = $jsonSearcher;
21
    }
22
23
    public function readJsonNodeValue($jsonNodeExpression)
24
    {
25
        return $this->jsonParser->evaluate(
26
            $this->readJson(),
27
            $jsonNodeExpression
28
        );
29
    }
30
31
    public function searchJsonPath($pathExpression)
32
    {
33
        return $this->jsonSearcher->search($this->readJson(), $pathExpression);
34
    }
35
36
    public function validateJson(JsonSchema $jsonSchema)
37
    {
38
        $this->jsonParser->validate(
39
            $this->readJson(),
40
            $jsonSchema
41
        );
42
    }
43
44
    public function readJson()
45
    {
46
        return $this->jsonStorage->readJson();
47
    }
48
49
    public function writeJson($jsonContent)
50
    {
51
        $this->jsonStorage->writeRawContent($jsonContent);
52
    }
53
}
54