1 | <?php |
||
34 | class CollectionSnapshot extends AbstractSnapshot |
||
35 | { |
||
36 | /** |
||
37 | * Collection of the new keys (extracted from the primary key) => old keys |
||
38 | * |
||
39 | * @var integer[] |
||
40 | */ |
||
41 | private $link = []; |
||
42 | |||
43 | /** |
||
44 | * Construct the snapshot |
||
45 | * |
||
46 | * The following options are taken into account : |
||
47 | * - snapshotClass : snapshot class to use for each elements. If none are |
||
48 | * given, the normalize() method will transform this into |
||
49 | * either an ArraySnapshot or an ObjectSnapshot, depending |
||
50 | * on the situation. |
||
51 | * |
||
52 | * @param mixed $data Either an array or a traversable, data to take a snapshot of |
||
53 | * @param mixed $primary Property path compatible value to use to get the primary key of each elements |
||
54 | * @param array $options Array of options |
||
55 | * |
||
56 | * @throws InvalidArgumentException the $data is not an array or a Traversable |
||
57 | * @throws InvalidArgumentException the $data is not an at least 2 dimensional array |
||
58 | * @throws InvalidArgumentException the snapshotClass in the options is not loadable |
||
59 | * @throws InvalidArgumentException the snapshotClass in the options is not a valid snapshot class |
||
60 | * @throws InvalidArgumentException one of the elements of the collection does not have a $primary key |
||
61 | */ |
||
62 | public function __construct($data, $primary, array $options = []) |
||
107 | |||
108 | /** |
||
109 | * Snapshots a value |
||
110 | * |
||
111 | * If the value is already a snapshot, it won't be snapshotted ; otherwise, |
||
112 | * if the class is null, then the value will be left as is. |
||
113 | * |
||
114 | * @param mixed $value Value to snapshot |
||
115 | * @param string $class Class to use to snapshot the value |
||
116 | * |
||
117 | * @return mixed A snapshot if the value was snapshotted, the original value otherwise |
||
118 | */ |
||
119 | private function snapshot($value, $class = null) |
||
127 | |||
128 | /** |
||
129 | * Returns the original key for the primary key $primary |
||
130 | * |
||
131 | * @param mixed $primary Primary key to search |
||
132 | * |
||
133 | * @return integer original key |
||
134 | * @throws InvalidArgumentException primary key not found |
||
135 | */ |
||
136 | public function getOriginalKey($primary) { |
||
143 | } |
||
144 | |||
145 |