Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ChangeStatusLogFormatter
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 formatStatuses
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 getMessageKey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 extractParameters
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Extension\CentralAuth\LogFormatter;
4
5use LogFormatter;
6
7/**
8 * Handles the following log types:
9 * - globalauth/setstatus
10 * - suppress/setstatus
11 */
12class ChangeStatusLogFormatter extends LogFormatter {
13
14    private function formatStatuses( array $array ): string {
15        if ( $array !== [] ) {
16            $values = array_map( function ( $key ) {
17                return $this->msg( 'centralauth-log-status-' . $key )->text();
18            }, $array );
19            return $this->formatParameterValue( 'list', $values );
20        }
21        return $this->msg( 'centralauth-log-status-none' )->text();
22    }
23
24    /** @inheritDoc */
25    protected function getMessageKey() {
26        return 'logentry-globalauth-setstatus';
27    }
28
29    protected function extractParameters() {
30        if ( $this->entry->isLegacy() ) {
31            return parent::extractParameters();
32        }
33
34        [ 'added' => $added, 'removed' => $removed ] = $this->entry->getParameters();
35        return [
36            3 => $this->formatStatuses( $added ),
37            4 => $this->formatStatuses( $removed ),
38        ];
39    }
40
41}