Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ListenMetricsEntrySerializer
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 serialize
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Wikispeech\Api;
4
5/**
6 * @file
7 * @ingroup API
8 * @ingroup Extensions
9 * @license GPL-2.0-or-later
10 */
11
12/**
13 * @since 0.1.10
14 */
15class ListenMetricsEntrySerializer {
16
17    /**
18     * @since 0.1.10
19     * @param ListenMetricsEntry $instance
20     * @return array Associative array that can be encoded using json_encode
21     */
22    public function serialize( ListenMetricsEntry $instance ): array {
23        $array = [
24            'timestamp' => $instance->getTimestamp()->getTimestamp( TS_UNIX ),
25            'segmentIndex' => $instance->getSegmentIndex(),
26            'segmentHash' => $instance->getSegmentHash(),
27            'remoteWikiHash' => $instance->getRemoteWikiHash(),
28            'consumerUrl' => $instance->getConsumerUrl(),
29            'pageTitle' => $instance->getPageTitle(),
30            'pageId' => $instance->getPageId(),
31            'pageRevisionId' => $instance->getPageRevisionId(),
32            'language' => $instance->getLanguage(),
33            'voice' => $instance->getVoice(),
34            'microsecondsSpent' => $instance->getMicrosecondsSpent(),
35            'utteranceSynthesized' => $instance->getUtteranceSynthesized(),
36            'millisecondsSpeechInUtterance' => $instance->getMillisecondsSpeechInUtterance(),
37            'charactersInSegment' => $instance->getCharactersInSegment(),
38        ];
39        if ( $instance->getId() !== null ) {
40            $array['id'] = $instance->getId();
41        }
42        return $array;
43    }
44}