Gateway::completePurchase()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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