/**
  * Find the relevant MemberApiKey object for the given key
  */
 public static function findByKey($key)
 {
     $matches = MemberApiKey::get()->filter(['ApiKey' => $key]);
     switch ($matches->count()) {
         case 1:
             return $matches->first();
         case 0:
             return null;
         default:
             throw new LogicException("Multiple MemberApiKey records for '{$key}' - database corrupt!");
     }
 }