Passed
Push — master ( ff7474...c002dd )
by Gabriel
05:50
created

Gateway::isActive()   B

Complexity

Conditions 7
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 9
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
ccs 0
cts 9
cp 0
crap 56
rs 8.8333
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Librapay;
4
5
use ByTIC\Omnipay\Librapay\Gateway as AbstractGateway;
6
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\GatewayTrait;
7
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\OverwriteServerCompletePurchaseTrait;
8
use ByTIC\Payments\Gateways\Providers\Librapay\Message\PurchaseRequest;
9
use Omnipay\Common\Message\RequestInterface;
10
11
/**
12
 * Class Gateway
13
 * @package ByTIC\Payments\Gateways\Providers\Librapay
14
 */
15
class Gateway extends AbstractGateway
16
{
17
    use GatewayTrait;
18
    use OverwriteServerCompletePurchaseTrait;
19
20
    /**
21
     * @inheritdoc
22
     * @return PurchaseRequest
23
     */
24
    public function purchase(array $parameters = []): RequestInterface
25
    {
26
        $parameters['endpointUrl'] = $this->getEndpointUrl();
27
28
        return $this->createRequestWithInternalCheck('PurchaseRequest', $parameters);
29
    }
30
31
    /**
32
     * @return bool
33
     */
34
    public function isActive()
35
    {
36
        if (
37
            strlen($this->getMerchant()) > 5
38
            && strlen($this->getTerminal()) > 5
39
            && strlen($this->getKey()) > 5
40
            && strlen($this->getMerchantName()) > 5
41
            && strlen($this->getMerchantEmail()) > 5
42
            && strlen($this->getMerchantUrl()) > 5
43
        ) {
44
            return true;
45
        }
46
47
        return false;
48
    }
49
}
50