Completed
Branch develop (8166a6)
by Romain
01:52
created

Payment   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A jsonSerialize() 0 11 1
1
<?php
2
namespace Kerox\Messenger\Model\Common\Buttons;
3
4
use Kerox\Messenger\Model\Common\Buttons\Payment\PaymentSummary;
5
6
class Payment extends AbstractButtons
7
{
8
9
    /**
10
     * @var string
11
     */
12
    protected $title;
13
14
    /**
15
     * @var string
16
     */
17
    protected $payload;
18
19
    /**
20
     * @var \Kerox\Messenger\Model\Common\Buttons\Payment\PaymentSummary
21
     */
22
    protected $paymentSummary;
23
24
    /**
25
     * Payment constructor.
26
     *
27
     * @param string $payload
28
     * @param \Kerox\Messenger\Model\Common\Buttons\Payment\PaymentSummary $paymentSummary
29
     */
30
    public function __construct(string $payload, PaymentSummary $paymentSummary)
31
    {
32
        parent::__construct(self::TYPE_PAYMENT);
33
34
        $this->isValidString($payload, 1000);
35
36
        $this->title = 'buy';
37
        $this->payload = $payload;
38
        $this->paymentSummary = $paymentSummary;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function jsonSerialize(): array
45
    {
46
        $json = parent::jsonSerialize();
47
        $json += [
48
            'title' => $this->title,
49
            'payload' => $this->payload,
50
            'payment_summary' => $this->paymentSummary,
51
        ];
52
53
        return $json;
54
    }
55
}
56