Form::getDataFromModel()   A
last analyzed

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 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 6
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Stripe;
4
5
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Form as AbstractForm;
6
use ByTIC\Payments\Models\Methods\Types\CreditCards;
7
8
/**
9
 * Class Form
10
 * @package ByTIC\Payments\Stripe
11
 */
12
class Form extends AbstractForm
13
{
14
    public function initElements()
15
    {
16
        parent::initElements();
17
        $this->initElementSandbox();
18
19
        $this->addInput('apiKey', 'apiKey', false);
20
        $this->addInput('publicKey', 'publicKey', false);
21
    }
22
23
    public function getDataFromModel()
24
    {
25
        $type = $this->getForm()->getModel()->getType();
26
        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...
27
            $type->getGateway();
28
        }
29
        parent::getDataFromModel();
30
    }
31
32
    /**
33
     * @return bool
34
     */
35
    public function process()
36
    {
37
        parent::process();
38
39
        $model = $this->getForm()->getModel();
40
        $options = $model->getPaymentGatewayOptions();
41
        $model->setPaymentGatewayOptions($options);
42
        $model->saveRecord();
43
44
        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...
45
    }
46
}
47