Transaction::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Sebdesign\VivaPayments\Responses;
4
5
use Sebdesign\VivaPayments\Enums\TransactionStatus;
6
use Sebdesign\VivaPayments\Enums\TransactionType;
7
8
class Transaction
9
{
10 1
    public function __construct(
11
        public readonly string $email,
12
        public readonly int $amount,
13
        public readonly string $orderCode,
14
        public readonly TransactionStatus $statusId,
15
        public readonly string $fullName,
16
        public readonly string $insDate,
17
        public readonly string $cardNumber,
18
        public readonly string $currencyCode,
19
        public readonly string $customerTrns,
20
        public readonly string $merchantTrns,
21
        public readonly TransactionType $transactionTypeId,
22
        public readonly bool $recurringSupport,
23
        public readonly int $totalInstallments,
24
        public readonly ?string $cardCountryCode,
25
        public readonly ?string $cardIssuingBank,
26
        public readonly int $currentInstallment,
27
        public readonly string $cardUniqueReference,
28
        public readonly int $cardTypeId,
29
        public readonly ?int $digitalWalletId = null,
30
    ) {
31
    }
32
33
    /** @phpstan-param  TransactionArray  $attributes */
34 3
    public static function create(array $attributes): self
35
    {
36 3
        return new self(...[
0 ignored issues
show
Bug introduced by
array($attributes, 'stat...['transactionTypeId'])) of type Sebdesign\VivaPayments\E...s\TransactionType|array is incompatible with the type string expected by parameter $email 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

36
        return new self(/** @scrutinizer ignore-type */ ...[
Loading history...
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

36
        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...
37
            ...$attributes,
38 3
            'statusId' => TransactionStatus::from($attributes['statusId']),
39 3
            'transactionTypeId' => TransactionType::from($attributes['transactionTypeId']),
40
        ]);
41
    }
42
}
43