/**
  * @dataProvider provider_requires_private_key
  *
  * @param $type
  * @param $expected
  */
 public function test_requires_private_key($type, $expected)
 {
     $this->assertSame($expected, LaunchKey_WP_Implementation_Type::requires_private_key($type));
 }
 /**
  * @param array $input
  * @param array $errors
  * @param array $options
  */
 private function process_standard_options(&$input, &$errors, &$options)
 {
     if (empty($input[LaunchKey_WP_Options::OPTION_ROCKET_KEY])) {
         $errors[] = $this->wp_facade->__('Rocket Key is a required field', $this->language_domain);
     } else {
         $rocket_key = trim($input[LaunchKey_WP_Options::OPTION_ROCKET_KEY]);
         if (!is_numeric($rocket_key)) {
             $errors[] = $this->wp_facade->__('Rocket Key must be numeric', $this->language_domain);
         } elseif (strlen($rocket_key) !== 10) {
             $errors[] = $this->wp_facade->__('Rocket Key must be 10 digits', $this->language_domain);
         } else {
             $options[LaunchKey_WP_Options::OPTION_ROCKET_KEY] = $rocket_key;
         }
     }
     if (empty($input[LaunchKey_WP_Options::OPTION_SECRET_KEY]) && empty($options[LaunchKey_WP_Options::OPTION_SECRET_KEY])) {
         $errors[] = $this->wp_facade->__('Secret Key is a required field', $this->language_domain);
     } else {
         if (!empty($input[LaunchKey_WP_Options::OPTION_SECRET_KEY])) {
             $secret_key = trim($input[LaunchKey_WP_Options::OPTION_SECRET_KEY]);
             if (!ctype_alnum($secret_key)) {
                 $errors[] = $this->wp_facade->__('Secret Key must be alphanumeric', $this->language_domain);
             } elseif (strlen($secret_key) !== 32) {
                 $errors[] = $this->wp_facade->__('Secret Key must be 32 characters', $this->language_domain);
             } else {
                 $options[LaunchKey_WP_Options::OPTION_SECRET_KEY] = $secret_key;
             }
         }
     }
     $app_display_name = isset($input[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME]) ? trim($input[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME]) : null;
     if ('LaunchKey' !== $app_display_name && LaunchKey_WP_Implementation_Type::WHITE_LABEL !== $options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE]) {
         $errors[] = $this->wp_facade->__('App Display Name can only be modified for White Label implementations', $this->language_domain);
         $options[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME] = 'LaunchKey';
     } else {
         $options[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME] = $app_display_name ?: null;
     }
     if (empty($_FILES['private_key']['tmp_name']) && empty($options[LaunchKey_WP_Options::OPTION_PRIVATE_KEY]) && isset($options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE]) && LaunchKey_WP_Implementation_Type::requires_private_key($options[LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE])) {
         $errors[] = $this->wp_facade->__('Private Key is required', $this->language_domain);
     } else {
         if (!empty($_FILES['private_key']['tmp_name'])) {
             $private_key = @file_get_contents($_FILES['private_key']['tmp_name']);
             $rsa = new Crypt_RSA();
             if (@$rsa->loadKey($private_key)) {
                 if ($rsa->getPrivateKey($rsa->privateKeyFormat)) {
                     $options[LaunchKey_WP_Options::OPTION_PRIVATE_KEY] = $private_key;
                 } else {
                     $errors[] = $this->wp_facade->__('The Key file provided was a valid RSA key file but did not contain a private key.  Did you mistakenly supply the public key file?', $this->language_domain);
                 }
             } else {
                 $errors[] = $this->wp_facade->__('The Private Key provided was invalid', $this->language_domain);
             }
         }
     }
 }