Passed
Push — master ( d0265c...1b1a87 )
by MusikAnimal
07:34
created

BlameRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setContainer() 0 5 1
A getEditFromRevId() 0 3 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace AppBundle\Repository;
5
6
use AppBundle\Model\Edit;
7
use AppBundle\Model\Page;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
10
/**
11
 * BlameRepository is responsible for retrieving authorship data about a single page.
12
 * @codeCoverageIgnore
13
 */
14
class BlameRepository extends AuthorshipRepository
15
{
16
    /** @var EditRepository Instance of EditRepository. */
17
    protected $editRepo;
18
19
    /**
20
     * Set the EditRepository once the container is available.
21
     * @param ContainerInterface $container
22
     */
23
    public function setContainer(ContainerInterface $container): void
24
    {
25
        parent::setContainer($container);
26
        $this->editRepo = new EditRepository();
27
        $this->editRepo->setContainer($this->container);
28
    }
29
30
    /**
31
     * Get an Edit given the revision ID.
32
     * @param Page $page Given so that the Edit will point to the same instance, rather than create a new Page.
33
     * @param int $revId
34
     * @return Edit
35
     */
36
    public function getEditFromRevId(Page $page, int $revId): Edit
37
    {
38
        return $this->editRepo->getEditFromRevIdForPage($page->getProject(), $revId, $page);
39
    }
40
}
41