GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 6dd769...c3d4a1 )
by Kevin
06:45 queued 03:07
created

SagePay::pay()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 32
Code Lines 19

Duplication

Lines 3
Ratio 9.38 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 3
loc 32
rs 8.8571
cc 3
eloc 19
nc 4
nop 1
1
<?php
2
3
namespace Magium\Magento\Actions\Checkout\PaymentMethods;
4
5
use Facebook\WebDriver\WebDriverSelect;
6
use Magium\Magento\AbstractMagentoTestCase;
7
use Magium\Magento\Actions\Checkout\PaymentInformation;
8
use Magium\Magento\Identities\Customer;
9
use Magium\WebDriver\WebDriver;
10
11
class SagePay implements PaymentMethodInterface
12
{
13
14
    const ACTION = 'Checkout\PaymentMethods\SagePay';
15
16
    protected $webDriver;
17
    protected $testCase;
18
    protected $paymentInformation;
19
    protected $customer;
20
    protected $assertion;
21
22 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
        WebDriver                   $webDriver,
24
        AbstractMagentoTestCase     $testCase,
25
        PaymentInformation          $paymentInformation,
26
        Customer                    $customer,
27
        \Magium\Magento\Assertions\Checkout\PaymentMethods\SagePay                     $assertion
28
    ) {
29
        $this->webDriver    = $webDriver;
30
        $this->testCase     = $testCase;
31
        $this->paymentInformation = $paymentInformation;
32
        $this->customer = $customer;
33
        $this->assertion = $assertion;
34
    }
35
36
    public function getId()
37
    {
38
        return 'p_method_sagepaydirectpro';
39
    }
40
41
    public function pay($requirePayment)
42
    {
43
        if ($requirePayment) {
44
            $this->testCase->assertElementExists($this->getId());
45
        }
46
47 View Code Duplication
        if (!$this->webDriver->elementDisplayed('sagepaydirectpro_cc_owner')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
            $this->webDriver->getMouse()->click($this->webDriver->byId($this->getId())->getCoordinates());
49
        }
50
        $this->assertion->assert();
51
52
        $select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_cc_type'));
53
        $select->selectByValue($this->paymentInformation->getType());
54
55
        $this->webDriver->byId('sagepaydirectpro_cc_number')->clear();
56
        $this->webDriver->byId('sagepaydirectpro_cc_number')->sendKeys($this->paymentInformation->getCreditCardNumber());
57
58
        $select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_expiration'));
59
        $select->selectByValue($this->paymentInformation->getExpiryMonth());
60
61
        $select = new WebDriverSelect($this->webDriver->byId('sagepaydirectpro_expiration_yr'));
62
        $select->selectByValue($this->paymentInformation->getExpiryYear());
63
64
        $this->webDriver->byId('sagepaydirectpro_cc_cid')->clear();
65
        $this->webDriver->byId('sagepaydirectpro_cc_cid')->sendKeys($this->paymentInformation->getCvv());
66
67
        $this->webDriver->byId('sagepaydirectpro_cc_owner')->clear();
68
        $this->webDriver->byId('sagepaydirectpro_cc_owner')->sendKeys(
69
            $this->customer->getBillingFirstName() . ' ' . $this->customer->getBillingLastName()
70
        );
71
72
    }
73
}