Gateway   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
eloc 14
c 1
b 0
f 1
dl 0
loc 42
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A completePurchase() 0 6 1
A purchase() 0 5 1
A isActive() 0 12 6
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Romcard;
4
5
use Paytic\Omnipay\Romcard\Gateway as AbstractGateway;
6
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\GatewayTrait;
7
use ByTIC\Payments\Gateways\Providers\Romcard\Message\CompletePurchaseRequest;
8
use ByTIC\Payments\Gateways\Providers\Romcard\Message\PurchaseRequest;
9
use Omnipay\Common\Message\RequestInterface;
10
11
/**
12
 * Class Gateway
13
 * @package ByTIC\Payments\Gateways\Providers\Romcard
14
 */
15
class Gateway extends AbstractGateway
16
{
17
    use GatewayTrait;
18
19
    /** @noinspection PhpMissingParentCallCommonInspection
20
     * @inheritdoc
21
     * @return PurchaseRequest
22
     */
23 1
    public function purchase(array $parameters = []): RequestInterface
24
    {
25 1
        $parameters['endpointUrl'] = $this->getEndpointUrl();
26
27 1
        return $this->createRequestWithInternalCheck('PurchaseRequest', $parameters);
28
    }
29
30
    /** @noinspection PhpMissingParentCallCommonInspection
31
     * @inheritdoc
32
     * @return CompletePurchaseRequest
33
     */
34 3
    public function completePurchase(array $parameters = []): RequestInterface
35
    {
36
        /** @var CompletePurchaseRequest $request */
37 3
        $request = $this->createRequestWithInternalCheck('CompletePurchaseRequest', $parameters);
38 3
        $request->setSaleRequest($this->sale($parameters));
39 3
        return $request;
40
    }
41
42
    /**
43
     * @return bool
44
     */
45 1
    public function isActive()
46
    {
47 1
        if (strlen($this->getTerminal()) > 5
48 1
            && strlen($this->getKey()) > 5
49 1
            && strlen($this->getMerchantName()) > 5
50 1
            && strlen($this->getMerchantEmail()) > 5
51 1
            && strlen($this->getMerchantUrl()) > 5
52
        ) {
53 1
            return true;
54
        }
55
56 1
        return false;
57
    }
58
}
59