CreditCards::getEntryDescription()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 7
c 2
b 0
f 1
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
namespace ByTIC\Payments\Models\Methods\Types;
4
5
use ByTIC\Payments\Gateways\Traits\HasGatewaysTrait;
6
use ByTIC\Payments\Models\Methods\PaymentMethod;
7
use Nip\Helpers\View\Messages as MessagesHelper;
8
9
/**
10
 * Class Payment_Method_Type_Credit_Cards
11
 * @method PaymentMethod getItem()
12
 */
13
class CreditCards extends AbstractType
14
{
15
    protected $aliases = ['credit-cards','credit_cards'];
16
17
    use HasGatewaysTrait;
18
19
    /**
20
     * @return bool|string
21
     */
22
    public function getEntryDescription()
23
    {
24
        if (!$this->getGateway()) {
25
            return MessagesHelper::error(
26
                $this->getGatewaysManager()->getMessage('entry-payment.invalid')
27
            );
28
        } elseif (!$this->getGateway()->isActive()) {
0 ignored issues
show
Bug introduced by
The method isActive() does not exist on Omnipay\Common\GatewayInterface. It seems like you code against a sub-type of Omnipay\Common\GatewayInterface such as Paytic\Omnipay\Euplatesc\Gateway or ByTIC\Payments\Gateways\Providers\Paylike\Gateway or Paytic\Payments\Librapay\Gateway or Paytic\Payments\Payu\Gateway or Paytic\Payments\Stripe\Gateway or Paytic\Payments\Twispay\Gateway or ByTIC\Payments\Gateways\Providers\Romcard\Gateway or Paytic\Payments\Mobilpay\Gateway or Paytic\Payments\Simplify\Gateway or Paytic\Payments\PlatiOnline\Gateway. ( Ignorable by Annotation )

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

28
        } elseif (!$this->getGateway()->/** @scrutinizer ignore-call */ isActive()) {
Loading history...
29
            return MessagesHelper::error(
30
                $this->getGatewaysManager()->getMessage('entry-payment.inactive')
31
            );
32
        }
33
        return false;
34
    }
35
36
    /**
37
     * @return bool
38
     */
39
    public function checkConfirmRedirect()
40
    {
41
        if ($this->getGateway()) {
42
            return $this->getGateway()->isActive();
43
        }
44
        return false;
45
    }
46
47
    /**
48
     * @return mixed
49
     */
50 18
    public function getGatewayOptions()
51
    {
52 18
        $name = $this->getGatewayName();
53 18
        $methodOptions = $this->getItem()->getOption($name, []);
54 18
        $options['PaymentMethod'] = $this->getItem();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Loading history...
55 18
        $options = $options + $methodOptions;
56
57 18
        return $options;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 20
    public function getGatewayName()
64
    {
65 20
        return $this->getItem()->getOption('payment_gateway');
66
    }
67
}
68