Links::jsonSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace GoCardlessPayment\MandateCheckout;
4
5
use GoCardlessPayment\Makeable;
6
7
class Links implements \JsonSerializable
8
{
9
    use Makeable;
10
11
    public array $data = [];
12
13 1
    public function add(string $key, ?string $value = null): static
14
    {
15 1
        $this->data[$key] = $value;
16
17 1
        return $this;
18
    }
19
20
    public function addCreditor(?string $value = null): static
21
    {
22
        return $this->add('creditor', $value);
23
    }
24
25
    public function addCustomer(?string $value = null): static
26
    {
27
        return $this->add('customer', $value);
28
    }
29
30 1
    public function addCustomerBankAccount(?string $value = null): static
31
    {
32 1
        return $this->add('customer_bank_account', $value);
33
    }
34
35 1
    public function jsonSerialize(): array
36
    {
37 1
        return array_filter($this->data, fn ($i) => ! is_null($i) && $i !== '');
38
    }
39
}
40