Gateway::isActive()   A
last analyzed

Complexity

Conditions 6
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.2222
cc 6
nc 2
nop 0
crap 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