Passed
Push — master ( c52187...71f110 )
by Sébastien
02:19
created

RecurringTransaction::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Sebdesign\VivaPayments\Responses;
4
5
use Sebdesign\VivaPayments\Enums\TransactionStatus;
6
7
class RecurringTransaction
8
{
9 1
    public function __construct(
10
        public readonly ?string $Emv,
11
        public readonly float $Amount,
12
        public readonly TransactionStatus $StatusId,
13
        public readonly ?string $RedirectUrl,
14
        public readonly string $CurrencyCode,
15
        public readonly string $TransactionId,
16
        public readonly int $ReferenceNumber,
17
        public readonly string $AuthorizationId,
18
        public readonly string $RetrievalReferenceNumber,
19
        public readonly ?string $Loyalty,
20
        public readonly int $ThreeDSecureStatusId,
21
        public readonly int $ErrorCode,
22
        public readonly ?string $ErrorText,
23
        public readonly string $TimeStamp,
24
        public readonly ?string $CorrelationId,
25
        public readonly int $EventId,
26
        public readonly bool $Success,
27
    ) {
28
    }
29
30
    /** @phpstan-param  RecurringTransactionArray  $attributes */
31 3
    public static function create(array $attributes): self
32
    {
33 3
        return new self(...[
0 ignored issues
show
Bug introduced by
The call to Sebdesign\VivaPayments\R...nsaction::__construct() has too few arguments starting with Amount. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        return /** @scrutinizer ignore-call */ new self(...[

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
array($attributes, 'Stat...ttributes['StatusId'])) of type Sebdesign\VivaPayments\E...TransactionStatus|array is incompatible with the type null|string expected by parameter $Emv of Sebdesign\VivaPayments\R...nsaction::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        return new self(/** @scrutinizer ignore-type */ ...[
Loading history...
34
            ...$attributes,
35 3
            'StatusId' => TransactionStatus::from($attributes['StatusId']),
36
        ]);
37
    }
38
}
39