1: <?php
2: /**
3: * PHP version 5
4: * @package generalDriver
5: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
6: * @author Stefan Heimes <stefan_heimes@hotmail.com>
7: * @author Tristan Lins <tristan.lins@bit3.de>
8: * @copyright The MetaModels team.
9: * @license LGPL.
10: * @filesource
11: */
12:
13: namespace DcGeneral\Data;
14:
15: use DcGeneral\Exception\DcGeneralInvalidArgumentException;
16:
17: /**
18: * A generic bag containing properties and their values.
19: */
20: interface PropertyValueBagInterface
21: extends
22: \IteratorAggregate,
23: \Countable,
24: \ArrayAccess
25: {
26: /**
27: * Check if a property exists in this bag.
28: *
29: * @param string $property The name of the property to check.
30: *
31: * @return bool
32: */
33: public function hasPropertyValue($property);
34:
35: /**
36: * Return the value of a property.
37: *
38: * @param string $property The name of the property to check.
39: *
40: * @return mixed
41: *
42: * @throws DcGeneralInvalidArgumentException If the property is not contained within the bag.
43: */
44: public function getPropertyValue($property);
45:
46: /**
47: * Set the value of a property.
48: *
49: * @param string $property The name of the property to set.
50: *
51: * @param mixed $value The value to use.
52: *
53: * @return PropertyValueBag
54: */
55: public function setPropertyValue($property, $value);
56:
57: /**
58: * Remove the value of a property.
59: *
60: * @param string $property The name of the property to remove.
61: *
62: * @return PropertyValueBag
63: *
64: * @throws DcGeneralInvalidArgumentException If the property is not contained within the bag.
65: */
66: public function removePropertyValue($property);
67:
68: /**
69: * Check if this bag contains invalid property values.
70: *
71: * @return bool
72: */
73: public function hasInvalidPropertyValues();
74:
75: /**
76: * Check if this bag contains no invalid property values.
77: *
78: * @return bool
79: */
80: public function hasNoInvalidPropertyValues();
81:
82: /**
83: * Check if a property value is invalid.
84: *
85: * @param string $property The name of the property to check.
86: *
87: * @return bool
88: */
89: public function isPropertyValueInvalid($property);
90:
91: /**
92: * Check if a property value is valid.
93: *
94: * @param string $property The name of the property to check.
95: *
96: * @return bool
97: */
98: public function isPropertyValueValid($property);
99:
100: /**
101: * Mark a property as invalid and add an error message to the property.
102: *
103: * @param string $property The name of the property to mark.
104: *
105: * @param string|array|mixed $error The error message to attach for this property.
106: *
107: * @param bool $append Append this error and keep previous errors (optional).
108: *
109: * @return PropertyValueBag
110: */
111: public function markPropertyValueAsInvalid($property, $error, $append = true);
112:
113: /**
114: * Reset the state of a property and remove all errors.
115: *
116: * @param string $property The name of the property to reset.
117: *
118: * @return PropertyValueBag
119: */
120: public function resetPropertyValueErrors($property);
121:
122: /**
123: * Get a list of all property names, whose values are invalid.
124: *
125: * @return string[]
126: */
127: public function getInvalidPropertyNames();
128:
129: /**
130: * Return all errors of an invalid property value.
131: *
132: * @param string $property The name of the property to retrieve the errors for.
133: *
134: * @return array
135: */
136: public function getPropertyValueErrors($property);
137:
138: /**
139: * Get an associative array of properties and their errors, whose values are invalid.
140: *
141: * @return array
142: */
143: public function getInvalidPropertyErrors();
144:
145: /**
146: * Exports the {@link PropertyValueBag} to an array.
147: *
148: * @return array
149: */
150: public function getArrayCopy();
151: }
152: