ReturnUrls   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 6 2
A __construct() 0 4 1
1
<?php
2
3
namespace GoCardlessPayment\MandateCheckout;
4
5
use GoCardlessPayment\Makeable;
6
7
/**
8
 * @see https://developer.gocardless.com/api-reference#billing-request-flows-create-a-billing-request-flow
9
 */
10
class ReturnUrls implements \JsonSerializable
11
{
12
    use Makeable;
13
14
    public readonly string $successUrl;
15
16
    public ?string $cancelUrl = null;
17
18 1
    public function __construct(string $successUrl, ?string $cancelUrl = null)
19
    {
20 1
        $this->successUrl = $successUrl;
0 ignored issues
show
Bug introduced by
The property successUrl is declared read-only in GoCardlessPayment\MandateCheckout\ReturnUrls.
Loading history...
21 1
        $this->cancelUrl = $cancelUrl;
22
    }
23
24 1
    public function jsonSerialize(): array
25
    {
26 1
        return array_filter([
27 1
            'redirect_uri' => $this->successUrl,
28 1
            'exit_uri' => $this->cancelUrl ?: $this->successUrl,
29 1
        ], fn ($i) => ! is_null($i));
30
    }
31
}
32