Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
4 / 7
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
PolicyMessagesLookup
57.14% covered (warning)
57.14%
4 / 7
66.67% covered (warning)
66.67%
2 / 3
3.71
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getPolicyMessageForRegistration
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getPolicyMessageForRegistrationForm
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare( strict_types=1 );
4
5namespace MediaWiki\Extension\CampaignEvents;
6
7use MediaWiki\Extension\CampaignEvents\Hooks\CampaignEventsHookRunner;
8
9class PolicyMessagesLookup {
10    public const SERVICE_NAME = 'CampaignEventsPolicyMessagesLookup';
11
12    private CampaignEventsHookRunner $hookRunner;
13
14    /**
15     * @param CampaignEventsHookRunner $hookRunner
16     */
17    public function __construct( CampaignEventsHookRunner $hookRunner ) {
18        $this->hookRunner = $hookRunner;
19    }
20
21    /**
22     * Looks for a policy message that should be shown to participants when registering for an event.
23     *
24     * @return string|null Message key, or null if there's no policy acknowledgement to display.
25     *  The message may contain wikitext.
26     */
27    public function getPolicyMessageForRegistration(): ?string {
28        $msg = null;
29        $this->hookRunner->onCampaignEventsGetPolicyMessageForRegistration( $msg );
30        return $msg;
31    }
32
33    /**
34     * Looks for a policy message that should be shown in the enable/edit registration form.
35     *
36     * @return string|null Message key, or null if there's no message to display.
37     *  The message may contain wikitext.
38     */
39    public function getPolicyMessageForRegistrationForm(): ?string {
40        $msg = null;
41        $this->hookRunner->onCampaignEventsGetPolicyMessageForRegistrationForm( $msg );
42        return $msg;
43    }
44}