Completed
Push — master ( 0c873a...10905b )
by Anılcan
04:51
created

Field::setRules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace AnilcanCakir\Former\Fields;
4
5
use AnilcanCakir\Former\Form;
6
7
abstract class Field
8
{
9
    /**
10
     * The form of field.
11
     *
12
     * @var Form
13
     */
14
    protected $form;
15
16
    /**
17
     * The name of field.
18
     *
19
     * @var string
20
     */
21
    protected $name;
22
23
    /**
24
     * The template of field.
25
     *
26
     * @var string
27
     */
28
    protected $template = 'fields.input';
29
30
    /**
31
     * The rules of field.
32
     *
33
     * @var array
34
     */
35
    protected $rules;
36
37
    /**
38
     * Get the name of field.
39
     *
40
     * @return string
41
     */
42
    public function getName(): string
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * Get the template of field.
49
     *
50
     * @return string
51
     */
52
    public function getTemplate(): string
53
    {
54
        return $this->template;
55
    }
56
57
    /**
58
     * Get the label of field.
59
     *
60
     * @return string
61
     */
62
    public function getLabel(): string
63
    {
64
        return $this->form->getHelper()->getLabel($this->name);
65
    }
66
67
    /**
68
     * Get the placeholder of field.
69
     *
70
     * @return null|string
71
     */
72
    public function getPlaceholder()
73
    {
74
        return $this->form->getHelper()->getPlaceholder($this->name);
75
    }
76
77
    /**
78
     * Get the text of field.
79
     *
80
     * @return null|string
81
     */
82
    public function getText()
83
    {
84
        return $this->form->getHelper()->getText($this->name);
85
    }
86
87
    /**
88
     * Set the name of field.
89
     *
90
     * @param string $name
91
     */
92
    public function setName(string $name)
93
    {
94
        $this->name = $name;
95
    }
96
97
    /**
98
     * Set the rules of field.
99
     *
100
     * @param array $rules
101
     */
102
    public function setRules(array $rules)
103
    {
104
        $this->rules = $rules;
105
    }
106
107
    /**
108
     * Set the form of field.
109
     *
110
     * @param Form $form
111
     */
112
    public function setForm(Form $form)
113
    {
114
        $this->form = $form;
115
    }
116
}