Passed
Pull Request — master (#83)
by Romain
03:05
created

PriceList::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Model\Common\Button\Payment;
6
7
class PriceList implements \JsonSerializable
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $label;
13
14
    /**
15
     * @var string
16
     */
17
    protected $amount;
18
19
    /**
20
     * PriceList constructor.
21
     *
22
     * @param string $label
23 2
     * @param string $amount
24
     */
25 2
    public function __construct(string $label, string $amount)
26 2
    {
27 2
        $this->label = $label;
28
        $this->amount = $amount;
29
    }
30
31
    /**
32 1
     * @param string $label
33
     * @param string $amount
34
     *
35 1
     * @return \Kerox\Messenger\Model\Common\Button\Payment\PriceList
36 1
     */
37
    public static function create(string $label, string $amount): self
38
    {
39
        return new self($label, $amount);
40
    }
41
42
    /**
43
     * @return array
44
     */
45
    public function toArray(): array
46
    {
47
        return [
48
            'label'  => $this->label,
49
            'amount' => $this->amount,
50
        ];
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function jsonSerialize(): array
57
    {
58
        return $this->toArray();
59
    }
60
}
61