NodeScalarValue   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 3 1
A __construct() 0 7 3
A getPath() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Data\Value\DecodedJson;
6
7
use Remorhaz\JSON\Data\Path\PathInterface;
8
use Remorhaz\JSON\Data\Value\NodeValueInterface;
9
use Remorhaz\JSON\Data\Value\ScalarValueInterface;
10
11
final class NodeScalarValue implements NodeValueInterface, ScalarValueInterface
12
{
13
14
    private $data;
15
16
    private $path;
17
18
    public function __construct($data, PathInterface $path)
19
    {
20
        if (null !== $data && !is_scalar($data)) {
21
            throw new Exception\InvalidNodeDataException($data, $path);
22
        }
23
        $this->data = $data;
24
        $this->path = $path;
25
    }
26
27
    public function getData()
28
    {
29
        return $this->data;
30
    }
31
32
    public function getPath(): PathInterface
33
    {
34
        return $this->path;
35
    }
36
}
37