Passed
Push — master ( 8ed01e...08cfff )
by Romain
02:40
created

Payment::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 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 1
    public function __construct(string $payload, PaymentSummary $paymentSummary)
32
    {
33 1
        parent::__construct(self::TYPE_PAYMENT);
34
35 1
        $this->isValidString($payload, 1000);
36
37 1
        $this->title = 'buy';
38 1
        $this->payload = $payload;
39 1
        $this->paymentSummary = $paymentSummary;
40 1
    }
41
42
    /**
43
     * @return array
44
     */
45 1
    public function jsonSerialize(): array
46
    {
47 1
        $json = parent::jsonSerialize();
48
        $json += [
49 1
            'title' => $this->title,
50 1
            'payload' => $this->payload,
51 1
            'payment_summary' => $this->paymentSummary,
52
        ];
53
54 1
        return $json;
55
    }
56
}
57