Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
6 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ApiFancyCaptchaReload
75.00% covered (warning)
75.00%
6 / 8
0.00% covered (danger)
0.00%
0 / 1
5.39
0.00% covered (danger)
0.00%
0 / 1
 execute
75.00% covered (warning)
75.00%
6 / 8
0.00% covered (danger)
0.00%
0 / 1
2.06
 isInternal
n/a
0 / 0
n/a
0 / 0
1
 getAllowedParams
n/a
0 / 0
n/a
0 / 0
1
 getExamplesMessages
n/a
0 / 0
n/a
0 / 0
1
1<?php
2
3namespace MediaWiki\Extension\ConfirmEdit\FancyCaptcha;
4
5use MediaWiki\Api\ApiBase;
6
7/**
8 * Api module to reload FancyCaptcha
9 *
10 * @ingroup API
11 * @ingroup Extensions
12 */
13class ApiFancyCaptchaReload extends ApiBase {
14    public function execute() {
15        $result = $this->getResult();
16
17        if ( $this->getUser()->pingLimiter( 'badcaptcha', 1 ) ) {
18            $result->addValue( null, $this->getModuleName(), [ 'index' => 0 ] );
19            return;
20        }
21
22        # Get a new FancyCaptcha form data
23        $captcha = new FancyCaptcha();
24        $info = $captcha->getCaptcha();
25        $captchaIndex = $captcha->storeCaptcha( $info );
26
27        $result->addValue( null, $this->getModuleName(), [ 'index' => $captchaIndex ] );
28    }
29
30    /**
31     * @inheritDoc
32     * @codeCoverageIgnore Merely declarative
33     */
34    public function isInternal() {
35        return true;
36    }
37
38    /**
39     * @inheritDoc
40     * @codeCoverageIgnore Merely declarative
41     */
42    public function getAllowedParams() {
43        return [];
44    }
45
46    /**
47     * @see ApiBase::getExamplesMessages()
48     * @return array
49     * @codeCoverageIgnore Merely declarative
50     */
51    protected function getExamplesMessages() {
52        return [
53            'action=fancycaptchareload'
54                => 'apihelp-fancycaptchareload-example-1',
55        ];
56    }
57}