Passed
Push — master ( 19a915...d9efc8 )
by Gabriel
14:56
created

PurchaseParameters   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
c 1
b 0
f 1
dl 0
loc 34
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A for() 0 28 1
1
<?php
2
3
namespace ByTIC\Payments\Actions\Purchases;
4
5
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableTrait;
6
7
/**
8
 * Class PurchaseParameters
9
 * @package ByTIC\Payments\Actions\Purchases
10
 */
11
class PurchaseParameters
12
{
13
    /**
14
     * @param IsPurchasableTrait $purchase
15
     * @return array
16
     */
17
    public static function for($purchase): array
18
    {
19
        $parameters = [];
20
        $parameters['amount'] = $purchase->getPurchaseAmount();
21
        $parameters['currency'] = $purchase->getPurchaseCurrency();
22
23
        $parameters['orderId'] = $purchase->id;
24
        $parameters['orderName'] = $purchase->getPurchaseName();
25
        $parameters['orderDate'] = $purchase->getPurchaseDate();
26
27
        $parameters['transactionId'] = $purchase->id;
28
        $parameters['description'] = $purchase->getPurchaseName();
29
        $parameters['lang'] = translator()->getLanguage();
0 ignored issues
show
Deprecated Code introduced by
The function Nip\I18n\Translator::getLanguage() has been deprecated: Use getLocale instead ( Ignorable by Annotation )

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

29
        $parameters['lang'] = /** @scrutinizer ignore-deprecated */ translator()->getLanguage();

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
30
31
        $parameters['items'] = [
32
            [
33
                'name' => $purchase->getPurchaseName(),
34
                'price' => $purchase->getPurchaseAmount(),
35
                'description' => $purchase->getPurchaseName(),
36
                'quantity' => 1,
37
            ],
38
        ];
39
40
        $parameters['returnUrl'] = $purchase->getConfirmURL();
0 ignored issues
show
Bug introduced by
It seems like getConfirmURL() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

40
        /** @scrutinizer ignore-call */ 
41
        $parameters['returnUrl'] = $purchase->getConfirmURL();
Loading history...
41
        $parameters['notifyUrl'] = $purchase->getIpnURL();
0 ignored issues
show
Bug introduced by
It seems like getIpnURL() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

41
        /** @scrutinizer ignore-call */ 
42
        $parameters['notifyUrl'] = $purchase->getIpnURL();
Loading history...
42
43
        $parameters['card'] = $purchase->getPurchaseParametersCard();
44
        return $parameters;
45
    }
46
}