Payload::created()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace DarkMatter\Payload;
6
7
use DarkMatter\Payload\DomainPayloadInterface;
8
9
class Payload implements DomainPayloadInterface
10
{
11
    protected $status;
12
13
    protected $result;
14
15
    public function __construct(string $status, array $result)
16
    {
17
        $this->status = $status;
18
        $this->result = $result;
19
    }
20
21
    public function getStatus() : string
22
    {
23
        return $this->status;
24
    }
25
26
    public function getResult() : array
27
    {
28
        return $this->result;
29
    }
30
31
    public static function created(array $result = []) : Payload
32
    {
33
        return new Payload(Status::CREATED, $result);
34
    }
35
36
    public static function deleted(array $result = []) : Payload
37
    {
38
        return new Payload(Status::DELETED, $result);
39
    }
40
41
    public static function notFound(array $result = []) : Payload
42
    {
43
        return new Payload(Status::NOT_FOUND, $result);
44
    }
45
46
    public static function found(array $result = []) : Payload
47
    {
48
        return new Payload(Status::FOUND, $result);
49
    }
50
51
    public static function invalid(array $result = []) : Payload
52
    {
53
        return new Payload(Status::INVALID, $result);
54
    }
55
56
    public static function success(array $result = []) : Payload
57
    {
58
        return new Payload(Status::SUCCESS, $result);
59
    }
60
61
    public static function updated(array $result = []) : Payload
62
    {
63
        return new Payload(Status::UPDATED, $result);
64
    }
65
66
    public static function error(array $result = []) : Payload
67
    {
68
        return new Payload(Status::ERROR, $result);
69
    }
70
71
    public static function processing(array $result = []) : Payload
72
    {
73
        return new Payload(Status::PROCESSING, $result);
74
    }
75
76
    public static function accepted(array $result = []) : Payload
77
    {
78
        return new Payload(Status::ACCEPTED, $result);
79
    }
80
}
81