Passed
Push — master ( 70edcf...7891a8 )
by Romain
48s
created

PolicyEnforcement   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 52
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getAction() 0 4 1
A getReason() 0 4 1
A create() 0 6 1
1
<?php
2
3
namespace Kerox\Messenger\Model\Callback;
4
5
class PolicyEnforcement
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $action;
11
12
    /**
13
     * @var null|string
14
     */
15
    protected $reason;
16
17
    /**
18
     * PolicyEnforcement constructor.
19
     *
20
     * @param string      $action
21
     * @param null|string $reason
22
     */
23 2
    public function __construct(string $action, $reason)
24
    {
25 2
        $this->action = $action;
26 2
        $this->reason = $reason;
27 2
    }
28
29
    /**
30
     * @return string
31
     */
32 1
    public function getAction(): string
33
    {
34 1
        return $this->action;
35
    }
36
37
    /**
38
     * @return null|string
39
     */
40 1
    public function getReason()
41
    {
42 1
        return $this->reason;
43
    }
44
45
    /**
46
     * @param array $payload
47
     *
48
     * @return \Kerox\Messenger\Model\Callback\PolicyEnforcement
49
     */
50 1
    public static function create(array $payload): PolicyEnforcement
51
    {
52 1
        $reason = $payload['reason'] ?? null;
53
54 1
        return new static($payload['action'], $reason);
55
    }
56
}
57