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
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-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Form;
15
16use Pop\Filter\FilterableTrait;
17use ReturnTypeWillChange;
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-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
26 * @license    http://www.popphp.org/license     New BSD License
27 * @version    3.6.0
28 */
29
30trait 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($name, $value);
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($name);
75
76    /**
77     * Return the isset value of values[$name]
78     *
79     * @param  string $name
80     * @return boolean
81     */
82    abstract public function __isset($name);
83
84    /**
85     * Unset values[$name]
86     *
87     * @param  string $name
88     * @return void
89     */
90    abstract public function __unset($name);
91
92    /**
93     * ArrayAccess offsetExists
94     *
95     * @param  mixed $offset
96     * @return boolean
97     */
98    public function offsetExists($offset): bool
99    {
100        return $this->__isset($offset);
101    }
102
103    /**
104     * ArrayAccess offsetGet
105     *
106     * @param  mixed $offset
107     * @return mixed
108     */
109    #[\ReturnTypeWillChange]
110    public function offsetGet($offset)
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    #[\ReturnTypeWillChange]
123    public function offsetSet($offset, $value)
124    {
125        $this->__set($offset, $value);
126    }
127
128    /**
129     * ArrayAccess offsetUnset
130     *
131     * @param  mixed $offset
132     * @return void
133     */
134    #[\ReturnTypeWillChange]
135    public function offsetUnset($offset)
136    {
137        $this->__unset($offset);
138    }
139
140}