Links   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 9
c 1
b 0
f 0
dl 0
loc 31
ccs 7
cts 11
cp 0.6364
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 5 1
A jsonSerialize() 0 3 2
A addCreditor() 0 3 1
A addCustomerBankAccount() 0 3 1
A addCustomer() 0 3 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