XPathType::jsonSerialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg\DataTypes\DataType\Text;
8
9
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\DataType as Upstream;
10
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\DataType\Text as Base;
11
12
/**
13
* @template T as XPathType
14
*
15
* @template-implements Base<T>
16
*/
17
class XPathType implements Base
18
{
19
    /**
20
    * @var string
21
    */
22
    protected $text;
23
24 1
    protected function __construct(string $text)
25
    {
26 1
        $this->text = $text;
27 1
    }
28
29 1
    public function __toString() : string
30
    {
31 1
        return $this->text;
32
    }
33
34 1
    public function DataTypeAsString() : string
35
    {
36 1
        return $this->text;
37
    }
38
39 1
    public function jsonSerialize() : string
40
    {
41 1
        return $this->DataTypeAsString();
42
    }
43
44
    /**
45
    * @psalm-return T
46
    */
47 1
    public static function DataTypeFromString(string $value) : Upstream
48
    {
49 1
        return new static($value);
50
    }
51
}
52