Adjustment::setName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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