ReturnUrls::jsonSerialize()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
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
/**
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