Back to Captcha class

Method getInstance

public static \Joomla\CMS\Captcha\Captcha|null
getInstance
(mixed $captcha, array $options = array())
Returns the global Captcha object, only creating it if it doesn't already exist.
Parameters
  • string $captcha The plugin to use.
  • array $options Associative array of options.
Returns
  • \Joomla\CMS\Captcha\Captcha|null Instance of this class.
Since
  • 2.5
-
  • \RuntimeException
Class: Captcha
Project: Joomla

Method getInstance - Source code

/**
 * Returns the global Captcha object, only creating it
 * if it doesn't already exist.
 *
 * @param   string  $captcha  The plugin to use.
 * @param   array   $options  Associative array of options.
 *
 * @return  Captcha|null  Instance of this class.
 *
 * @since   2.5
 * @throws  \RuntimeException
 */
public static function getInstance($captcha, array $options = array())
{
    $signature = md5(serialize(array($captcha, $options)));
    if (empty(self::$instances[$signature])) {
        self::$instances[$signature] = new Captcha($captcha, $options);
    }
    return self::$instances[$signature];
}