Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
RecoveryCodeCountPresentationModel
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 getIconType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPrimaryLink
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getSecondaryLinks
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
 getBodyMessage
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\OATHAuth\Notifications;
4
5use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel;
6use MediaWiki\Extension\OATHAuth\Key\TOTPKey;
7use MediaWiki\SpecialPage\SpecialPage;
8use MediaWiki\Title\Title;
9
10class RecoveryCodeCountPresentationModel extends EchoEventPresentationModel {
11
12    /** @inheritDoc */
13    public function getIconType() {
14        return 'site';
15    }
16
17    /** @inheritDoc */
18    public function getPrimaryLink() {
19        return [
20            'url' => SpecialPage::getTitleFor( 'OATHManage' )->getLocalURL(),
21            'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-primary' )->text()
22        ];
23    }
24
25    /** @inheritDoc */
26    public function getSecondaryLinks() {
27        $link = $this->msg( 'oathauth-notifications-recoverycodesleft-helplink' )->inContentLanguage();
28        $title = Title::newFromText( $link->plain() );
29        if ( !$title ) {
30            // Invalid title, skip
31            return [];
32        }
33        return [ [
34            'url' => $title->getLocalURL(),
35            'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-help' )->text(),
36            'icon' => 'help',
37        ] ];
38    }
39
40    /** @inheritDoc */
41    public function getBodyMessage() {
42        $msg = $this->getMessageWithAgent( 'notification-body-oathauth-recoverycodesleft' );
43        $msg->params( $this->event->getExtraParam( 'codeCount', 0 ) );
44        $msg->params( $this->event->getExtraParam( 'generatedCount', TOTPKey::RECOVERY_CODES_COUNT ) );
45        return $msg;
46    }
47
48}