Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
RevisionHandler
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
 factory
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
 getRevision
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\IPInfo\Rest\Handler;
4
5use JobQueueGroup;
6use MediaWiki\IPInfo\InfoManager;
7use MediaWiki\IPInfo\Rest\Presenter\DefaultPresenter;
8use MediaWiki\IPInfo\TempUserIPLookup;
9use MediaWiki\Languages\LanguageFallback;
10use MediaWiki\Permissions\PermissionManager;
11use MediaWiki\Registration\ExtensionRegistry;
12use MediaWiki\Revision\RevisionLookup;
13use MediaWiki\Revision\RevisionRecord;
14use MediaWiki\User\Options\UserOptionsLookup;
15use MediaWiki\User\UserFactory;
16use MediaWiki\User\UserIdentityUtils;
17
18class RevisionHandler extends AbstractRevisionHandler {
19
20    private RevisionLookup $revisionLookup;
21
22    public function __construct(
23        InfoManager $infoManager,
24        RevisionLookup $revisionLookup,
25        PermissionManager $permissionManager,
26        UserOptionsLookup $userOptionsLookup,
27        UserFactory $userFactory,
28        DefaultPresenter $presenter,
29        JobQueueGroup $jobQueueGroup,
30        LanguageFallback $languageFallback,
31        UserIdentityUtils $userIdentityUtils,
32        TempUserIPLookup $tempUserIPLookup,
33        ExtensionRegistry $extensionRegistry
34    ) {
35        parent::__construct(
36            $infoManager,
37            $permissionManager,
38            $userOptionsLookup,
39            $userFactory,
40            $presenter,
41            $jobQueueGroup,
42            $languageFallback,
43            $userIdentityUtils,
44            $tempUserIPLookup,
45            $extensionRegistry
46        );
47        $this->revisionLookup = $revisionLookup;
48    }
49
50    public static function factory(
51        InfoManager $infoManager,
52        RevisionLookup $revisionLookup,
53        PermissionManager $permissionManager,
54        UserOptionsLookup $userOptionsLookup,
55        UserFactory $userFactory,
56        JobQueueGroup $jobQueueGroup,
57        LanguageFallback $languageFallback,
58        UserIdentityUtils $userIdentityUtils,
59        TempUserIPLookup $tempUserIPLookup,
60        ?ExtensionRegistry $extensionRegistry = null
61    ): self {
62        return new self(
63            $infoManager,
64            $revisionLookup,
65            $permissionManager,
66            $userOptionsLookup,
67            $userFactory,
68            new DefaultPresenter( $permissionManager ),
69            $jobQueueGroup,
70            $languageFallback,
71            $userIdentityUtils,
72            $tempUserIPLookup,
73            $extensionRegistry ?? ExtensionRegistry::getInstance()
74        );
75    }
76
77    /** @inheritDoc */
78    protected function getRevision( int $id ): ?RevisionRecord {
79        return $this->revisionLookup->getRevisionById( $id );
80    }
81}