Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
ImportTopic
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 11
182
0.00% covered (danger)
0.00%
0 / 1
 getText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getAuthor
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRevisions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getReplies
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getTimestamp
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTopicSummary
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
 getSummaryId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getObjectKey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLogType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLogParameters
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 getLqtThreadId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Flow\Import\LiquidThreadsApi;
4
5use ArrayIterator;
6use Flow\Import\IImportSummary;
7use Flow\Import\IImportTopic;
8use Flow\Import\IObjectRevision;
9
10/**
11 * This is a bit of a weird model, acting as a revision of itself.
12 */
13class ImportTopic extends ImportPost implements IImportTopic, IObjectRevision {
14    /**
15     * @return string
16     */
17    public function getText() {
18        return $this->apiResponse['subject'];
19    }
20
21    public function getAuthor() {
22        return $this->apiResponse['author']['name'];
23    }
24
25    public function getRevisions() {
26        // we only have access to a single revision of the topic
27        return new ArrayIterator( [ $this ] );
28    }
29
30    public function getReplies() {
31        $topPost = new ImportPost( $this->importSource, $this->apiResponse );
32
33        return new ArrayIterator( [ $topPost ] );
34    }
35
36    public function getTimestamp() {
37        return wfTimestamp( TS_MW, $this->apiResponse['created'] );
38    }
39
40    /**
41     * @return IImportSummary|null
42     */
43    public function getTopicSummary() {
44        $id = $this->getSummaryId();
45        if ( $id > 0 ) {
46            $data = $this->importSource->getPageData( $id );
47            if ( isset( $data['revisions'][0] ) ) {
48                return new ImportSummary( $data, $this->importSource );
49            } else {
50                return null;
51            }
52        } else {
53            return null;
54        }
55    }
56
57    /**
58     * @return int
59     */
60    protected function getSummaryId() {
61        return $this->apiResponse['summaryid'];
62    }
63
64    /**
65     * This needs to have a different value than the same apiResponse in an ImportPost.
66     * The ImportPost version refers to the first response to the topic.
67     * @return string
68     */
69    public function getObjectKey() {
70        return 'topic' . $this->importSource->getObjectKey( 'thread_id', $this->apiResponse['id'] );
71    }
72
73    public function getLogType() {
74        return "lqt-to-flow-topic";
75    }
76
77    public function getLogParameters() {
78        return [
79            'lqt_thread_id' => $this->apiResponse['id'],
80            'lqt_orig_title' => $this->getTitle()->getPrefixedText(),
81            'lqt_subject' => $this->getText(),
82        ];
83    }
84
85    public function getLqtThreadId() {
86        return $this->apiResponse['id'];
87    }
88}