@@ -167,16 +167,31 @@ public function add(string $discord, string $ss14): void
167167
168168 public function remove (string $ discord , string $ ss14 = '' ): ?array
169169 {
170- $ existingIndex = $ this ->getIndex ($ discord , $ ss14 );
171- if ( $ existingIndex === false ) return null ;
172- return $ this ->removeIndex ($ existingIndex );
170+ return ( $ existingIndex = $ this ->getIndex ($ discord , $ ss14 )) === false
171+ ? null
172+ : $ this ->removeIndex ($ existingIndex );
173173 }
174174
175- public function getIndex ( string $ discord , string $ ss14 = '' ): int | string | false
175+ public function fetch ( int | string $ key , string $ value ): ? array
176176 {
177177 $ list = $ this ->state ->getVerifyList ();
178- $ existingIndex = array_search ($ discord , array_column ($ list , 'discord ' ));
179- if ($ ss14 && $ existingIndex === false ) $ existingIndex = array_search ($ ss14 , array_column ($ list , 'ss14 ' ));
180- return $ existingIndex ;
178+ return ($ existingIndex = array_search ($ value , array_column ($ list , $ key ))) === false
179+ ? null
180+ : $ list [$ existingIndex ] ?? null ;
181+ }
182+
183+ public function getIndex (string $ discord = '' , string $ ss14 = '' ): int |string |false
184+ {
185+ if ($ discord === '' && $ ss14 === '' ) return false ;
186+ $ list = $ this ->state ->getVerifyList ();
187+ if ($ discord !== '' ) {
188+ $ index = array_search ($ discord , array_column ($ list , 'discord ' ));
189+ if ($ index !== false ) return $ index ;
190+ }
191+ if ($ ss14 !== '' ) {
192+ $ index = array_search ($ ss14 , array_column ($ list , 'ss14 ' ));
193+ if ($ index !== false ) return $ index ;
194+ }
195+ return false ;
181196 }
182197}
0 commit comments