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

Data   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 2
b 0
f 0
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toJson() 0 3 1
A __construct() 0 3 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