Response::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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