Passed
Push — master ( 0ccfee...416c42 )
by Radu
07:10
created

Data::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WebServCo\Framework\Json;
6
7
/**
8
* A basic JSON data object.
9
* Used in Json\Response
10
*/
11
class Data implements \WebServCo\Framework\Interfaces\JsonInterface
12
{
13
14
    /**
15
    * Data
16
    *
17
    * @var array<mixed>
18
    */
19
    protected array $data;
20
21
    /**
22
    * @param array<mixed> $data
23
    */
24
    public function __construct(array $data = [])
25
    {
26
        $this->data = $data;
27
    }
28
29
    public function toJson(): string
30
    {
31
        return (string) \json_encode($this->data);
32
    }
33
}
34