Response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 15
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 7 1
A toArray() 0 3 1
1
<?php
2
3
4
namespace Tohidplus\Paravel\Response;
5
6
use JsonSerializable;
7
8
class Response implements JsonSerializable
9
{
10
    protected bool $status = true;
11
    protected array $error = [];
12
    protected $result;
13
    private string $label;
14
15
    /**
16
     * Response constructor.
17
     * @param string $label
18
     * @param bool $status
19
     * @param mixed $result
20
     * @param array $error
21
     */
22
    public function __construct(string $label, bool $status, $result, array $error = [])
23
    {
24
        $this->status = $status;
25
        $this->result = $result;
26
        $this->error = $error;
27
        $this->label = $label;
28
    }
29
30
    public function jsonSerialize()
31
    {
32
        return [
33
            'label'=>$this->label,
34
            'status' => $this->status,
35
            'result' => $this->result,
36
            'error' => $this->error
37
        ];
38
    }
39
40
    public function toArray()
41
    {
42
        return $this->jsonSerialize();
43
    }
44
}
45