Payment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 55
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A create() 0 4 1
A toArray() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Common\Button;
6
7
use Kerox\Messenger\Model\Common\Button\Payment\PaymentSummary;
8
9
class Payment extends AbstractButton
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $title;
15
16
    /**
17
     * @var string
18
     */
19
    protected $payload;
20
21
    /**
22
     * @var \Kerox\Messenger\Model\Common\Button\Payment\PaymentSummary
23
     */
24
    protected $paymentSummary;
25
26
    /**
27
     * Payment constructor.
28
     *
29
     * @throws \Kerox\Messenger\Exception\MessengerException
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
     * @throws \Kerox\Messenger\Exception\MessengerException
44
     *
45
     * @return \Kerox\Messenger\Model\Common\Button\Payment
46
     */
47 1
    public static function create(string $payload, PaymentSummary $paymentSummary): self
48
    {
49 1
        return new self($payload, $paymentSummary);
50
    }
51
52 1
    public function toArray(): array
53
    {
54 1
        $array = parent::toArray();
55
        $array += [
56 1
            'title' => $this->title,
57 1
            'payload' => $this->payload,
58 1
            'payment_summary' => $this->paymentSummary,
59
        ];
60
61 1
        return $array;
62
    }
63
}
64