JsonStorage::readJson()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Rezzza\RestApiBehatExtension\Json;
4
5
use Rezzza\RestApiBehatExtension\Rest\ResponseStorage;
6
7
/**
8
 * Store the JSON that we could analyze it in JsonContext
9
 */
10
class JsonStorage implements ResponseStorage
11
{
12
    private $rawContent;
13
14
    public function writeRawContent($rawContent)
15
    {
16
        $this->rawContent = $rawContent;
17
    }
18
19
    public function readJson()
20
    {
21
        if ($this->rawContent === null) {
22
            throw new \LogicException('No content defined. You should use JsonStorage::writeRawContent method to inject content you want to analyze');
23
        }
24
25
        return new Json($this->rawContent);
26
    }
27
}
28