Links::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
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