JsonData::fromBoolean()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PascalDeVink\CloudEvents\V03;
6
7
final class JsonData implements Data
8
{
9
    /**
10
     * @var mixed
11
     */
12
    private $data;
13
14
    private ContentEncoding $contentEncoding;
15
16
    private function __construct($data, ContentEncoding $contentEncoding)
17
    {
18
        $this->data            = $data;
19
        $this->contentEncoding = $contentEncoding;
20
    }
21
22
    public static function fromString(string $data, ContentEncoding $contentEncoding) : self
23
    {
24
        return new self($data, $contentEncoding);
25
    }
26
27
    public static function fromInteger(int $data, ContentEncoding $contentEncoding) : self
28
    {
29
        return new self($data, $contentEncoding);
30
    }
31
32
    public static function fromBoolean(bool $data, ContentEncoding $contentEncoding) : self
33
    {
34
        return new self($data, $contentEncoding);
35
    }
36
37
    public static function fromArray(array $data, ContentEncoding $contentEncoding) : self
38
    {
39
        return new self($data, $contentEncoding);
40
    }
41
42
    public function getContentType() : ContentType
43
    {
44
        return new ContentType('application/json');
45
    }
46
47
    public function getContentEncoding() : ContentEncoding
48
    {
49
        return $this->contentEncoding;
50
    }
51
52
    public function getData()
53
    {
54
        return $this->data;
55
    }
56
}
57