AbstractSegmentFieldModifier::getForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\Forms\SegmentFieldModifier;
4
5
use ReflectionClass;
6
use SilverStripe\Forms\SegmentField;
7
use SilverStripe\Forms\SegmentFieldModifier;
8
9
abstract class AbstractSegmentFieldModifier implements SegmentFieldModifier
10
{
11
    public function __construct()
12
    {
13
        // required so that ReflectionInstance::newInstanceArgs doesn't fail
14
    }
15
16
    /**
17
     * @var mixed
18
     */
19
    protected $form;
20
21
    /**
22
     * @var SegmentField
23
     */
24
    protected $field;
25
26
    /**
27
     * @var mixed
28
     */
29
    protected $request;
30
31
    /**
32
     * @inheritdoc
33
     *
34
     * @param mixed $form
35
     *
36
     * @return $this
37
     */
38
    public function setForm($form)
39
    {
40
        $this->form = $form;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getForm()
49
    {
50
        return $this->form;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     *
56
     * @param SegmentField $field
57
     *
58
     * @return $this
59
     */
60
    public function setField(SegmentField $field)
61
    {
62
        $this->field = $field;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @return SegmentField
69
     */
70
    public function getField()
71
    {
72
        return $this->field;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     *
78
     * @param mixed $request
79
     *
80
     * @return $this
81
     */
82
    public function setRequest($request)
83
    {
84
        $this->request = $request;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @return mixed
91
     */
92
    public function getRequest()
93
    {
94
        return $this->request;
95
    }
96
97
    /**
98
     * @return static
99
     */
100
    public static function create()
101
    {
102
        $reflection = new ReflectionClass(get_called_class());
103
104
        if (func_num_args()) {
105
            return $reflection->newInstanceArgs(func_get_args());
106
        } else {
107
            return $reflection->newInstance();
108
        }
109
    }
110
}
111