1 | <?php |
||
29 | abstract class AbstractSnapshot implements ArrayAccess |
||
30 | { |
||
31 | /** @var array data stored in an array */ |
||
32 | protected $data = []; |
||
33 | |||
34 | /** @var mixed raw data stored */ |
||
35 | protected $raw; |
||
36 | |||
37 | /** @var string Set class to use */ |
||
38 | private $setClass = 'Totem\\Set'; |
||
39 | |||
40 | public function setSetClass($class) |
||
50 | |||
51 | /** |
||
52 | * Calculate the diff between two snapshots |
||
53 | * |
||
54 | * @param AbstractSnapshot $snapshot Snapshot to compare this one to |
||
55 | * |
||
56 | * @return Set Changeset between the two snapshots |
||
57 | * @throws IncomparableDataException If the two snapshots are not comparable |
||
58 | */ |
||
59 | public function diff(AbstractSnapshot $snapshot) |
||
70 | |||
71 | /** |
||
72 | * Get the raw data fed to this snapshot |
||
73 | * |
||
74 | * @return mixed |
||
75 | */ |
||
76 | final public function getRawData() |
||
80 | |||
81 | /** |
||
82 | * Get the computed data, transformed into an array by this constructor |
||
83 | * |
||
84 | * @return SnapshotInterface[] |
||
85 | * @throws InvalidArgumentException If the data is not an array |
||
86 | */ |
||
87 | final public function getComparableData() |
||
95 | |||
96 | /** |
||
97 | * Returns the keys of the data |
||
98 | * |
||
99 | * @return array |
||
100 | * @throws InvalidArgumentException If the frozen data is not an array |
||
101 | */ |
||
102 | final public function getDataKeys() |
||
106 | |||
107 | /** |
||
108 | * Clone this object |
||
109 | * |
||
110 | * @codeCoverageIgnore |
||
111 | */ |
||
112 | final private function __clone() |
||
115 | |||
116 | /** {@inheritDoc} */ |
||
117 | final public function offsetExists($offset) |
||
121 | |||
122 | /** {@inheritDoc} */ |
||
123 | final public function offsetGet($offset) |
||
127 | |||
128 | /** |
||
129 | * {@inheritDoc} |
||
130 | * |
||
131 | * @throws BadMethodCallException if a unset is tried on a snapshot property |
||
132 | */ |
||
133 | final public function offsetSet($offset, $value) |
||
137 | |||
138 | /** |
||
139 | * {@inheritDoc} |
||
140 | * |
||
141 | * @throws BadMethodCallException if a unset is tried on a snapshot property |
||
142 | */ |
||
143 | final public function offsetUnset($offset) |
||
147 | |||
148 | /** |
||
149 | * Check if the two snapshots are comparable |
||
150 | * |
||
151 | * @param AbstractSnapshot $snapshot Snapshot to be compared with |
||
152 | * |
||
153 | * @return boolean true if the two snapshots can be processed in a diff, false otherwise |
||
154 | */ |
||
155 | public function isComparable(AbstractSnapshot $snapshot) |
||
163 | |||
164 | /** |
||
165 | * Finish data initialization |
||
166 | * |
||
167 | * To be called by child classes *after* the data has been initialized |
||
168 | */ |
||
169 | protected function normalize() |
||
196 | } |
||
197 | |||
198 |