Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
WikiExporterFactory
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getWikiExporter
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\Export;
8
9use MediaWiki\CommentStore\CommentStore;
10use MediaWiki\HookContainer\HookContainer;
11use MediaWiki\Revision\RevisionStore;
12use MediaWiki\Title\TitleParser;
13use Wikimedia\Rdbms\IReadableDatabase;
14
15/**
16 * Factory service for WikiExporter instances.
17 *
18 * @author Zabe
19 * @since 1.38
20 */
21class WikiExporterFactory {
22    /** @var HookContainer */
23    private $hookContainer;
24
25    /** @var RevisionStore */
26    private $revisionStore;
27
28    /** @var TitleParser */
29    private $titleParser;
30
31    /** @var CommentStore */
32    private $commentStore;
33
34    /**
35     * @param HookContainer $hookContainer
36     * @param RevisionStore $revisionStore
37     * @param TitleParser $titleParser
38     * @param CommentStore $commentStore
39     */
40    public function __construct(
41        HookContainer $hookContainer,
42        RevisionStore $revisionStore,
43        TitleParser $titleParser,
44        CommentStore $commentStore
45    ) {
46        $this->hookContainer = $hookContainer;
47        $this->revisionStore = $revisionStore;
48        $this->titleParser = $titleParser;
49        $this->commentStore = $commentStore;
50    }
51
52    /**
53     * @param IReadableDatabase $db
54     * @param int|array $history
55     * @param int $text
56     * @param null|array $limitNamespaces
57     *
58     * @return WikiExporter
59     */
60    public function getWikiExporter(
61        IReadableDatabase $db,
62        $history = WikiExporter::CURRENT,
63        $text = WikiExporter::TEXT,
64        $limitNamespaces = null
65    ): WikiExporter {
66        return new WikiExporter(
67            $db,
68            $this->commentStore,
69            $this->hookContainer,
70            $this->revisionStore,
71            $this->titleParser,
72            $history,
73            $text,
74            $limitNamespaces
75        );
76    }
77}