Passed
Push — master ( 3c0766...793f0f )
by Chris
05:28
created

AbstractField::getRequestVar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Controllers;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use WebTheory\Saveyour\Contracts\DataTransformerInterface;
7
use WebTheory\Saveyour\Contracts\FieldDataManagerInterface;
8
use WebTheory\Saveyour\Contracts\FieldOperationCacheInterface;
9
use WebTheory\Saveyour\Contracts\FormFieldControllerInterface;
10
use WebTheory\Saveyour\Contracts\FormFieldInterface;
11
12
abstract class AbstractField implements FormFieldControllerInterface
13
{
14
    /**
15
     * @var FormFieldControllerInterface
16
     */
17
    protected $controller;
18
19
    /**
20
     * @var string
21
     */
22
    protected $requestVar;
23
24
    /**
25
     *
26
     */
27
    public function __construct(string $requestVar)
28
    {
29
        $this->requestVar = $requestVar;
30
        $this->controller = $this->createFormFieldController();
31
    }
32
33
    /**
34
     * Get the value of requestVar
35
     *
36
     * @return string
37
     */
38
    public function getRequestVar(): string
39
    {
40
        return $this->requestVar;
41
    }
42
43
    /**
44
     *
45
     */
46
    public function getPresetValue(ServerRequestInterface $request)
47
    {
48
        return $this->controller->getPresetValue($request);
49
    }
50
51
    /**
52
     *
53
     */
54
    public function canProcessInput(): bool
55
    {
56
        return $this->controller->canProcessInput();
57
    }
58
59
    /**
60
     *
61
     */
62
    public function render(ServerRequestInterface $request): ?FormFieldInterface
63
    {
64
        return $this->controller->render($request);
65
    }
66
67
    /**
68
     *
69
     */
70
    public function process(ServerRequestInterface $request): FieldOperationCacheInterface
71
    {
72
        return $this->controller->process($request);
73
    }
74
75
    /**
76
     *
77
     */
78
    protected function createFormFieldController(): FormFieldControllerInterface
79
    {
80
        return new BaseFormFieldController(
81
            $this->getRequestVar(),
82
            $this->createFormField(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->createFormField() targeting WebTheory\Saveyour\Contr...ield::createFormField() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
83
            $this->createDataManager(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->createDataManager() targeting WebTheory\Saveyour\Contr...ld::createDataManager() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
84
            $this->createDataTransformer(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->createDataTransformer() targeting WebTheory\Saveyour\Contr...createDataTransformer() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
85
            $this->defineFilters(),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->defineFilters() targeting WebTheory\Saveyour\Contr...tField::defineFilters() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
86
            $this->defineRules()
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->defineRules() targeting WebTheory\Saveyour\Contr...actField::defineRules() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
87
        );
88
    }
89
90
    /**
91
     *
92
     */
93
    protected function createFormField(): ?FormFieldInterface
94
    {
95
        return null;
96
    }
97
98
    /**
99
     *
100
     */
101
    public function createDataManager(): ?FieldDataManagerInterface
102
    {
103
        return null;
104
    }
105
106
    /**
107
     *
108
     */
109
    protected function createDataTransformer(): ?DataTransformerInterface
110
    {
111
        return null;
112
    }
113
114
    /**
115
     *
116
     */
117
    protected function defineFilters(): ?array
118
    {
119
        return null;
120
    }
121
122
    /**
123
     *
124
     */
125
    protected function defineRules(): ?array
126
    {
127
        return null;
128
    }
129
}
130