Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
FormTrait | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
count | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
toArray | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getIterator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__set | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__get | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__isset | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
__unset | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
offsetExists | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetGet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
offsetUnset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Form; |
15 | |
16 | use Pop\Filter\FilterableTrait; |
17 | use ArrayIterator; |
18 | |
19 | /** |
20 | * Form trait |
21 | * |
22 | * @category Pop |
23 | * @package Pop\Form |
24 | * @author Nick Sagona, III <dev@nolainteractive.com> |
25 | * @copyright Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
26 | * @license http://www.popphp.org/license New BSD License |
27 | * @version 4.0.0 |
28 | */ |
29 | |
30 | trait FormTrait |
31 | { |
32 | |
33 | use FilterableTrait; |
34 | |
35 | /** |
36 | * Count of values |
37 | * |
38 | * @return int |
39 | */ |
40 | abstract public function count(): int; |
41 | |
42 | /** |
43 | * Get values |
44 | * |
45 | * @return array |
46 | */ |
47 | abstract public function toArray(): array; |
48 | |
49 | /** |
50 | * Method to iterate over the form elements |
51 | * |
52 | * @return ArrayIterator |
53 | */ |
54 | public function getIterator(): ArrayIterator |
55 | { |
56 | return new ArrayIterator($this->toArray()); |
57 | } |
58 | |
59 | /** |
60 | * Set method to set the property to the value of values[$name] |
61 | * |
62 | * @param string $name |
63 | * @param mixed $value |
64 | * @return void |
65 | */ |
66 | abstract public function __set(string $name, mixed $value): void; |
67 | |
68 | /** |
69 | * Get method to return the value of values[$name] |
70 | * |
71 | * @param string $name |
72 | * @return mixed |
73 | */ |
74 | abstract public function __get(string $name): mixed; |
75 | |
76 | /** |
77 | * Return the isset value of values[$name] |
78 | * |
79 | * @param string $name |
80 | * @return bool |
81 | */ |
82 | abstract public function __isset(string $name): bool; |
83 | |
84 | /** |
85 | * Unset values[$name] |
86 | * |
87 | * @param string $name |
88 | * @return void |
89 | */ |
90 | abstract public function __unset(string $name); |
91 | |
92 | /** |
93 | * ArrayAccess offsetExists |
94 | * |
95 | * @param mixed $offset |
96 | * @return bool |
97 | */ |
98 | public function offsetExists(mixed $offset): bool |
99 | { |
100 | return $this->__isset($offset); |
101 | } |
102 | |
103 | /** |
104 | * ArrayAccess offsetGet |
105 | * |
106 | * @param mixed $offset |
107 | * @return mixed |
108 | */ |
109 | public function offsetGet(mixed $offset): mixed |
110 | { |
111 | return $this->__get($offset); |
112 | } |
113 | |
114 | /** |
115 | * ArrayAccess offsetSet |
116 | * |
117 | * @param mixed $offset |
118 | * @param mixed $value |
119 | * @return void |
120 | */ |
121 | public function offsetSet(mixed $offset, mixed $value): void |
122 | { |
123 | $this->__set($offset, $value); |
124 | } |
125 | |
126 | /** |
127 | * ArrayAccess offsetUnset |
128 | * |
129 | * @param mixed $offset |
130 | * @return void |
131 | */ |
132 | public function offsetUnset(mixed $offset): void |
133 | { |
134 | $this->__unset($offset); |
135 | } |
136 | |
137 | } |