File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -644,13 +644,14 @@ protected function getHighestOrder()
644644 */
645645 public function get ($ key )
646646 {
647- if (is_int ($ key )) {
648- return $ this ->getByOrder ($ key );
649- } elseif (is_string ($ key )) {
650- return $ this ->getByKey ($ this ->getAuthoritativeName ($ key ));
647+ $ internalKey = $ this ->resolveInternalKey ($ key );
648+ if ($ internalKey === null ) {
649+ return null ;
651650 }
652651
653- return null ;
652+ return is_int ($ internalKey )
653+ ? $ this ->getByOrder ($ internalKey )
654+ : $ this ->getByKey ($ internalKey );
654655 }
655656
656657 /**
@@ -884,4 +885,22 @@ public function isNotEmpty()
884885 {
885886 return !$ this ->isEmpty ();
886887 }
888+
889+ /**
890+ * This returns the *internal* key used to store this data.
891+ *
892+ * @param string|int $key
893+ *
894+ * @return string|int|null
895+ */
896+ protected function resolveInternalKey ($ key ) {
897+ if (is_int ($ key )) {
898+ $ ordered = $ this ->getOrdered ();
899+ return isset ($ ordered [$ key ]) ? $ key : null ;
900+ } elseif (is_string ($ key )) {
901+ return $ this ->getAuthoritativeName ($ key );
902+ }
903+
904+ return null ;
905+ }
887906}
You can’t perform that action at this time.
0 commit comments