MediaWiki  1.34.0
CaptchaStore.php
Go to the documentation of this file.
1 <?php
2 
3 abstract class CaptchaStore {
9  abstract public function store( $index, $info );
10 
16  abstract public function retrieve( $index );
17 
22  abstract public function clear( $index );
23 
28  abstract public function cookiesNeeded();
29 
34  private static $instance;
35 
42  final public static function get() {
43  if ( !self::$instance instanceof self ) {
44  global $wgCaptchaStorageClass;
45  if ( in_array( 'CaptchaStore', class_parents( $wgCaptchaStorageClass ) ) ) {
46  self::$instance = new $wgCaptchaStorageClass;
47  } else {
48  throw new Exception( "Invalid CaptchaStore class $wgCaptchaStorageClass" );
49  }
50  }
51  return self::$instance;
52  }
53 
54  final public static function unsetInstanceForTests() {
55  if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
56  throw new MWException( 'Cannot unset ' . __CLASS__ . ' instance in operation.' );
57  }
58  self::$instance = null;
59  }
60 
64  protected function __construct() {
65  }
66 }
CaptchaStore\retrieve
retrieve( $index)
Retrieve the answer for a given captcha.
CaptchaStore\store
store( $index, $info)
Store the correct answer for a given captcha.
CaptchaStore\unsetInstanceForTests
static unsetInstanceForTests()
Definition: CaptchaStore.php:54
CaptchaStore\clear
clear( $index)
Delete a result once the captcha has been used, so it cannot be reused.
CaptchaStore\cookiesNeeded
cookiesNeeded()
Whether this type of CaptchaStore needs cookies.
MWException
MediaWiki exception.
Definition: MWException.php:26
CaptchaStore
Definition: CaptchaStore.php:3
CaptchaStore\$instance
static CaptchaStore $instance
The singleton instance.
Definition: CaptchaStore.php:34
CaptchaStore\__construct
__construct()
Protected constructor: no creating instances except through the factory method above.
Definition: CaptchaStore.php:64