Passed
Push — master ( 793f0f...d7ccbf )
by Chris
04:53
created

AbstractField::getFormField()   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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace WebTheory\Saveyour\Controllers;
4
5
use Psr\Http\Message\ServerRequestInterface;
6
use Respect\Validation\Validatable;
7
use WebTheory\Saveyour\Contracts\DataTransformerInterface;
8
use WebTheory\Saveyour\Contracts\FieldDataManagerInterface;
9
use WebTheory\Saveyour\Contracts\FieldOperationCacheInterface;
10
use WebTheory\Saveyour\Contracts\FormFieldControllerInterface;
11
use WebTheory\Saveyour\Contracts\FormFieldInterface;
12
13
abstract class AbstractField implements FormFieldControllerInterface
14
{
15
    /**
16
     * @var FormFieldControllerInterface
17
     */
18
    protected $__coreController;
19
20
    /**
21
     *
22
     */
23 3
    public function __construct(string $requestVar)
24
    {
25 3
        $this->__coreController = $this->createFormFieldController($requestVar);
26 3
    }
27
28
    /**
29
     * Get the value of requestVar
30
     *
31
     * @return string
32
     */
33 3
    public function getRequestVar(): string
34
    {
35 3
        return $this->__coreController->getRequestVar();
36
    }
37
38
    /**
39
     *
40
     */
41
    public function getFormField(): ?FormFieldInterface
42
    {
43
        return $this->__coreController->getFormField();
44
    }
45
46
    /**
47
     * @return Validatable[]
48
     */
49
    public function getRules(): array
50
    {
51
        return $this->__coreController->getRules();
52
    }
53
54
    /**
55
     * @return Validatable
56
     */
57
    public function getRule(string $rule): Validatable
58
    {
59
        return $this->__coreController->getRule($rule);
60
    }
61
62
    /**
63
     * @return callable[]
64
     */
65
    public function getFilters(): array
66
    {
67
        return $this->__coreController->getFilters();
68
    }
69
70
71
    /**
72
     * @return bool|mixed
73
     */
74
    public function filterInput($input)
75
    {
76
        return $this->__coreController->filterInput($input);
77
    }
78
79
    /**
80
     * @return array
81
     */
82
    public function getViolations(): array
83
    {
84
        return $this->__coreController->getViolations();
85
    }
86
    /**
87
     *
88
     */
89
    public function getPresetValue(ServerRequestInterface $request)
90
    {
91
        return $this->__coreController->getPresetValue($request);
92
    }
93
94
    /**
95
     *
96
     */
97
    public function canProcessInput(): bool
98
    {
99
        return $this->__coreController->canProcessInput();
100
    }
101
102
    /**
103
     *
104
     */
105
    public function render(ServerRequestInterface $request): ?FormFieldInterface
106
    {
107
        return $this->__coreController->render($request);
108
    }
109
110
    /**
111
     *
112
     */
113
    public function process(ServerRequestInterface $request): FieldOperationCacheInterface
114
    {
115
        return $this->__coreController->process($request);
116
    }
117
118
    /**
119
     *
120
     */
121 3
    protected function createFormFieldController(string $requestVar): FormFieldControllerInterface
122
    {
123 3
        return new BaseFormFieldController(
124 3
            $requestVar,
125 3
            $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...
126 3
            $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...
127 3
            $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...
128 3
            $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...
129 3
            $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...
130
        );
131
    }
132
133
    /**
134
     *
135
     */
136 3
    protected function createFormField(): ?FormFieldInterface
137
    {
138 3
        return null;
139
    }
140
141
    /**
142
     *
143
     */
144 3
    public function createDataManager(): ?FieldDataManagerInterface
145
    {
146 3
        return null;
147
    }
148
149
    /**
150
     *
151
     */
152 3
    protected function createDataTransformer(): ?DataTransformerInterface
153
    {
154 3
        return null;
155
    }
156
157
    /**
158
     *
159
     */
160 3
    protected function defineFilters(): ?array
161
    {
162 3
        return null;
163
    }
164
165
    /**
166
     *
167
     */
168 3
    protected function defineRules(): ?array
169
    {
170 3
        return null;
171
    }
172
}
173