Passed
Branch develop (7a155a)
by Gabriel
05:17
created

Form::getDataFromModel()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 10
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Paylike;
4
5
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Form as AbstractForm;
6
use ByTIC\Payments\Models\Methods\Types\CreditCards;
7
use Symfony\Component\HttpFoundation\File\UploadedFile;
8
9
/**
10
 * Class Form
11
 * @package ByTIC\Payments\Gateways\Providers\Paylike
12
 */
13
class Form extends AbstractForm
14
{
15
    public function initElements()
16
    {
17
        parent::initElements();
18
        $this->initElementSandbox();
19
20
        $this->addInput('public-key', 'Public key', false);
21
        $this->addInput('private-key', 'Private key', false);
22
    }
23
24
    public function getDataFromModel()
25
    {
26
        $type = $this->getForm()->getModel()->getType();
27
        if ($type instanceof CreditCards) {
0 ignored issues
show
introduced by
$type is never a sub-type of ByTIC\Payments\Models\Methods\Types\CreditCards.
Loading history...
28
            $type->getGateway();
29
        }
30
        parent::getDataFromModel();
31
    }
32
33
    /**
34
     * @return bool
35
     */
36
    public function processValidation()
37
    {
38
        parent::processValidation();
39
40
        return true;
41
    }
42
43
    /**
44
     * @return bool
45
     */
46
    public function process()
47
    {
48
        parent::process();
49
50
        $model = $this->getForm()->getModel();
51
        $options = $model->getPaymentGatewayOptions();
52
53
        $model->setPaymentGatewayOptions($options);
54
        $model->saveRecord();
55
56
        return $options;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $options returns the type Nip_Form which is incompatible with the documented return type boolean.
Loading history...
57
    }
58
}
59