ReturnUrls::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
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 4
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
/**
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