Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TranslationNotificationsLogFormatter
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 getMessageParameters
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\TranslationNotifications;
5
6use LogFormatter;
7use MediaWiki\Extension\TranslationNotifications\Utilities\NotificationMessageBuilder;
8
9/**
10 * Class for formatting TranslationNotifications logs.
11 * @author Sucheta Ghoshal
12 * @copyright Copyright © 2013, Sucheta Ghoshal
13 * @license GPL-2.0-or-later
14 */
15class TranslationNotificationsLogFormatter extends LogFormatter {
16    public function getMessageParameters(): array {
17        $params = parent::getMessageParameters();
18
19        // $params[3] is $languagesForLog,
20        // $params[4] is $deadlineDate,
21        // $params[5] is $priority
22        // $params[9] is $languageCount
23        // If no specific languages are defined, set languageForLog to 'all languages'.
24        if ( $params[3] === '' ) {
25            $params[3] = $this->msg( 'translationnotifications-log-alllanguages' )->text();
26            // Set language count to arbitrary high number for 'all languages'.
27            $params[9] = 999;
28        } else {
29            // If specific languages are defined, show them.
30            $params[9] = count( explode( ',', $params[3] ) );
31        }
32
33        if ( $params[4] === '' ) {
34            // If deadline is not set, deadlineDate is set to 'none'.
35            $params[4] = $this->msg( 'translationnotifications-nodeadline' )->text();
36        }
37        // possible messages here:
38        // 'translationnotifications-priority-high'
39        // 'translationnotifications-priority-low'
40        // 'translationnotifications-priority-medium'
41        // 'translationnotifications-priority-unset'
42        $params[5] = NotificationMessageBuilder::getPriorityMessage( $params[5] )
43            ->setContext( $this->context )
44            ->text();
45
46        return $params;
47    }
48}