@@ -96,9 +96,9 @@ public function hasMeta($key): bool {
96
96
if ( is_string ( $ key ) && preg_match ( '/[,|]/is ' , $ key ) ) {
97
97
$ key = preg_split ( '/ ?[,|] ?/ ' , $ key );
98
98
}
99
- $ setMeta = 'hasMeta ' . ucfirst ( gettype ( $ key ) );
99
+ $ hasMeta = 'hasMeta ' . ucfirst ( gettype ( $ key ) );
100
100
101
- return $ this ->$ setMeta ( $ key );
101
+ return $ this ->$ hasMeta ( $ key );
102
102
}
103
103
104
104
protected function hasMetaString ($ key ): bool {
@@ -183,6 +183,7 @@ public function getDefaultMetaValue($key) {
183
183
}
184
184
185
185
protected function getMetaString ($ key , $ default = null ) {
186
+ $ key = strtolower ( $ key );
186
187
$ meta = $ this ->getMetaData ()->get ( $ key );
187
188
188
189
if ( is_null ( $ meta ) || $ meta ->isMarkedForDeletion () ) {
@@ -195,16 +196,18 @@ protected function getMetaString($key, $default = null) {
195
196
196
197
protected function getMetaArray ($ keys , $ default = null ): BaseCollection {
197
198
$ collection = new BaseCollection ();
198
- $ flipped = array_flip ( $ keys );
199
- foreach ($ this ->getMetaData () as $ meta ) {
200
- if ( ! $ meta ->isMarkedForDeletion () && isset ( $ flipped [$ meta ->key ] ) ) {
201
- unset( $ flipped [$ meta ->key ] );
202
- $ collection ->put ( $ meta ->key , $ meta ->value );
199
+
200
+ foreach ($ keys as $ key ) {
201
+ $ key = strtolower ( $ key );
202
+ if ( $ this ->hasMeta ( $ key ) ) {
203
+ $ meta = $ this ->getMetaData ()[$ key ];
204
+ if ( ! $ meta ->isMarkedForDeletion () ) {
205
+ $ collection ->put ( $ key , $ meta ->value );
206
+ continue ;
207
+ }
203
208
}
204
- }
205
- // If there are any keys left in $flipped, it means they are not set. so fill them with default values.
206
- // Default values set in defaultMetaValues property take precedence over default values passed to this method
207
- foreach ($ flipped as $ key => $ value ) {
209
+ // Key does not exist, so it's value will be the default value
210
+ // Default values set in defaultMetaValues property take precedence over default value passed to this method
208
211
$ defaultValue = $ this ->getDefaultMetaValue ( $ key );
209
212
if ( is_null ( $ defaultValue ) ) {
210
213
if ( is_array ( $ default ) ) {
0 commit comments