Payload   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 72
c 0
b 0
f 0
wmc 13
lcom 1
cbo 0
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStatus() 0 4 1
A getResult() 0 4 1
A created() 0 4 1
A deleted() 0 4 1
A notFound() 0 4 1
A found() 0 4 1
A invalid() 0 4 1
A success() 0 4 1
A updated() 0 4 1
A error() 0 4 1
A processing() 0 4 1
A accepted() 0 4 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