Passed
Pull Request — main (#442)
by MusikAnimal
08:42 queued 04:18
created

BlameRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEditFromRevId() 0 3 1
A __construct() 0 13 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App\Repository;
6
7
use App\Model\Edit;
8
use App\Model\Page;
9
use GuzzleHttp\Client;
10
use Psr\Cache\CacheItemPoolInterface;
11
use Psr\Container\ContainerInterface;
12
use Psr\Log\LoggerInterface;
13
14
/**
15
 * BlameRepository is responsible for retrieving authorship data about a single page.
16
 * @codeCoverageIgnore
17
 */
18
class BlameRepository extends AuthorshipRepository
19
{
20
    protected EditRepository $editRepo;
21
    protected UserRepository $userRepo;
22
23
    public function __construct(
24
        ContainerInterface $container,
25
        CacheItemPoolInterface $cache,
26
        Client $guzzle,
27
        LoggerInterface $logger,
28
        bool $isWMF,
29
        int $queryTimeout,
30
        EditRepository $editRepo,
31
        UserRepository $userRepo
32
    ) {
33
        parent::__construct($container, $cache, $guzzle, $logger, $isWMF, $queryTimeout);
34
        $this->editRepo = $editRepo;
35
        $this->userRepo = $userRepo;
36
    }
37
38
    /**
39
     * Get an Edit given the revision ID.
40
     * @param Page $page Given so that the Edit will point to the same instance, rather than create a new Page.
41
     * @param int $revId
42
     * @return Edit|null null if not found.
43
     */
44
    public function getEditFromRevId(Page $page, int $revId): ?Edit
45
    {
46
        return $this->editRepo->getEditFromRevIdForPage($this->userRepo, $page->getProject(), $revId, $page);
47
    }
48
}
49