File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Equip \Data \Traits ;
4
+
5
+ /**
6
+ * Intended to be used by classes implementing Equip\Data\EntityInterface that
7
+ * also need to implement Equip\Data\DiffableInterface.
8
+ */
9
+ trait DiffableEntityTrait /* implements DiffableInterface */
10
+ {
11
+ /**
12
+ * @see \Equip\Data\EntityInterface::withData()
13
+ *
14
+ * @param array $data
15
+ *
16
+ * @return static
17
+ */
18
+ abstract public function withData (array $ data );
19
+
20
+ /**
21
+ * @see \Equip\Data\ArraySerializableInterface::toArray()
22
+ *
23
+ * @return array
24
+ */
25
+ abstract public function toArray ();
26
+
27
+ /**
28
+ * @param array $values
29
+ *
30
+ * @return array
31
+ */
32
+ public function diff (array $ values )
33
+ {
34
+ $ copy = $ this ->withData ($ values );
35
+ return array_diff_assoc ($ copy ->toArray (), $ this ->toArray ());
36
+ }
37
+ }
You can’t perform that action at this time.
0 commit comments