Passed
Push — master ( 0e21f4...195aeb )
by Romain
39s
created

Postback   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 60
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

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