1 | <?php |
||
53 | class AreMergeable |
||
54 | { |
||
55 | /** |
||
56 | * does it make sense to attempt to merge the contents of $theirs into |
||
57 | * $ours? |
||
58 | * |
||
59 | * @param mixed $ours |
||
60 | * where we want to merge to |
||
61 | * @param mixed $theirs |
||
62 | * where we want to merge from |
||
63 | * @return boolean |
||
64 | * true if merging makes sense |
||
65 | * false otherwise |
||
66 | */ |
||
67 | public static function into($ours, $theirs) |
||
68 | { |
||
69 | // we can't merge non-arrays, non-objects |
||
70 | if (!IsTraversable::check($theirs) && !IsAssignable::check($theirs)) { |
||
71 | return false; |
||
72 | } |
||
73 | |||
74 | // if we have arrays or databag-type objects, we're good |
||
75 | if (IsIndexable::check($ours) || IsAssignable::check($ours)) { |
||
76 | return true; |
||
77 | } |
||
78 | |||
79 | // if we get here, then $ours is a complex object, which |
||
80 | // we do not know how to merge |
||
81 | // |
||
82 | // or it is a scalar, which doesn't support merging at all |
||
83 | return false; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * does it make sense to attempt to merge the contents of $theirs into |
||
88 | * $ours? |
||
89 | * |
||
90 | * @deprecated since 2.2.0 |
||
91 | * @codeCoverageIgnore |
||
92 | * |
||
93 | * @param mixed $ours |
||
94 | * where we want to merge to |
||
95 | * @param mixed $theirs |
||
96 | * where we want to merge from |
||
97 | * @return boolean |
||
98 | * true if merging makes sense |
||
99 | * false otherwise |
||
100 | */ |
||
101 | public static function intoMixed($ours, $theirs) |
||
105 | |||
106 | /** |
||
107 | * does it make sense to attempt to merge the contents of $theirs into |
||
108 | * $ours? |
||
109 | * |
||
110 | * @param mixed $ours |
||
111 | * where we want to merge to |
||
112 | * @param mixed $theirs |
||
113 | * where we want to merge from |
||
114 | * @return boolean |
||
115 | * true if merging makes sense |
||
116 | * false otherwise |
||
117 | */ |
||
118 | public function __invoke($ours, $theirs) |
||
122 | |||
123 | } |
||
124 |