Completed
Pull Request — master (#53)
by Romain
03:15
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
3
namespace Kerox\Messenger\Model\Common\Button;
4
5
use Kerox\Messenger\Model\Common\Button\Payment\PaymentSummary;
6
7
class Payment extends AbstractButton
8
{
9
10
    /**
11
     * @var string
12
     */
13
    protected $title;
14
15
    /**
16
     * @var string
17
     */
18
    protected $payload;
19
20
    /**
21
     * @var \Kerox\Messenger\Model\Common\Button\Payment\PaymentSummary
22
     */
23
    protected $paymentSummary;
24
25
    /**
26
     * Payment constructor.
27
     *
28
     * @param string $payload
29
     * @param \Kerox\Messenger\Model\Common\Button\Payment\PaymentSummary $paymentSummary
30
     */
31
    public function __construct(string $payload, PaymentSummary $paymentSummary)
32
    {
33
        parent::__construct(self::TYPE_PAYMENT);
34
35
        $this->isValidString($payload, 1000);
36
37
        $this->title = 'buy';
38
        $this->payload = $payload;
39
        $this->paymentSummary = $paymentSummary;
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function jsonSerialize(): array
46
    {
47
        $json = parent::jsonSerialize();
48
        $json += [
49
            'title' => $this->title,
50
            'payload' => $this->payload,
51
            'payment_summary' => $this->paymentSummary,
52
        ];
53
54
        return $json;
55
    }
56
}
57