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