Passed
Push — master ( a30cf1...9051a7 )
by Gabriel
14:38
created

Form::initElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Stripe;
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\Stripe
12
 */
13
class Form extends AbstractForm
14
{
15
    public function initElements()
16
    {
17
        parent::initElements();
18
        $this->initElementSandbox();
19
20
        $this->addInput('apiKey', 'apiKey', 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