Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace MediaWiki\Extension\OATHAuth;
4
5use IContextSource;
6use MediaWiki\Auth\AbstractSecondaryAuthenticationProvider;
7use MediaWiki\Extension\OATHAuth\HTMLForm\IManageForm;
8use Message;
9
10interface IModule {
11    /**
12     * Name of the module, as declared in the OATHAuth.Modules extension.json attribute.
13     *
14     * @return string
15     */
16    public function getName();
17
18    /**
19     * @return Message
20     */
21    public function getDisplayName();
22
23    /**
24     * @param array $data
25     * @return IAuthKey
26     */
27    public function newKey( array $data );
28
29    /**
30     * @return AbstractSecondaryAuthenticationProvider
31     */
32    public function getSecondaryAuthProvider();
33
34    /**
35     * Is this module currently enabled for the given user?
36     *
37     * Arguably, module is enabled just by the fact its set on user,
38     * but it might not be true for all future modules
39     *
40     * @param OATHUser $user
41     * @return bool
42     */
43    public function isEnabled( OATHUser $user );
44
45    /**
46     * Run the validation
47     *
48     * @param OATHUser $user
49     * @param array $data
50     * @return bool
51     */
52    public function verify( OATHUser $user, array $data );
53
54    /**
55     * @param string $action
56     * @param OATHUser $user
57     * @param OATHUserRepository $repo
58     * @param IContextSource $context
59     * @return IManageForm|null if no form is available for given action
60     */
61    public function getManageForm(
62        $action,
63        OATHUser $user,
64        OATHUserRepository $repo,
65        IContextSource $context
66    );
67
68    /**
69     * Return Message object for the short text to be displayed as description
70     *
71     * @return Message
72     */
73    public function getDescriptionMessage();
74
75    /**
76     * Module-specific text that will be shown when the user is disabling
77     * the module, to warn of data-loss.
78     * This will be shown alongside the generic warning message.
79     *
80     * @return Message|null if no additional text is needed
81     */
82    public function getDisableWarningMessage();
83}