Total Complexity | 6 |
Total Lines | 99 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
21 | abstract class AbstractInput |
||
22 | { |
||
23 | /** |
||
24 | * |
||
25 | * The name for the input. |
||
26 | * |
||
27 | * @var string |
||
28 | * |
||
29 | */ |
||
30 | protected $name; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * The prefix for the name, typically composed of the parent input names. |
||
35 | * |
||
36 | * @var string |
||
37 | * |
||
38 | */ |
||
39 | protected $name_prefix; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * Sets the name for the input. |
||
44 | * |
||
45 | * @param string $name The input name. |
||
46 | * |
||
47 | * @return self |
||
48 | * |
||
49 | */ |
||
50 | public function setName($name) |
||
51 | { |
||
52 | $this->name = $name; |
||
53 | return $this; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | * Sets the name prefix for the input, typically composed of the parent |
||
59 | * input names. |
||
60 | * |
||
61 | * @param string $name_prefix The name prefix. |
||
62 | * |
||
63 | * @return self |
||
64 | * |
||
65 | */ |
||
66 | public function setNamePrefix($name_prefix) |
||
67 | { |
||
68 | $this->name_prefix = $name_prefix; |
||
69 | return $this; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * |
||
74 | * Returns the full name for this input, incuding the prefix (if any). |
||
75 | * |
||
76 | * @return string |
||
77 | * |
||
78 | */ |
||
79 | public function getFullName() |
||
80 | { |
||
81 | $name = $this->name; |
||
82 | if ($this->name_prefix) { |
||
83 | $name = $this->name_prefix . "[{$name}]"; |
||
84 | } |
||
85 | return $name; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * |
||
90 | * Support for this input when addressed via Fieldset::__get(). |
||
91 | * |
||
92 | * @return self |
||
93 | * |
||
94 | */ |
||
95 | public function read() |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * |
||
102 | * Returns this input for the presentation layer. |
||
103 | * |
||
104 | * @return self |
||
105 | * |
||
106 | */ |
||
107 | public function get() |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * |
||
114 | * Returns the value of this input for use in arrays. |
||
115 | * |
||
116 | * @return mixed |
||
117 | * |
||
118 | */ |
||
119 | abstract public function getValue(); |
||
120 | } |
||
121 |