GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( faf574...d9550b )
by Odiseo
02:45
created

ArticleCommentFactory::createNewWithArticle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 14
rs 10
1
<?php
2
3
namespace Odiseo\BlogBundle\Factory;
4
5
use Exception;
6
use Odiseo\BlogBundle\Doctrine\ORM\ArticleRepositoryInterface;
7
use Odiseo\BlogBundle\Model\ArticleCommentInterface;
8
use Odiseo\BlogBundle\Model\ArticleInterface;
9
10
final class ArticleCommentFactory implements ArticleCommentFactoryInterface
11
{
12
    /** @var string */
13
    private $className;
14
15
    /** @var ArticleRepositoryInterface */
16
    private $articleRepository;
17
18
    public function __construct(string $className, ArticleRepositoryInterface $articleRepository)
19
    {
20
        $this->className = $className;
21
        $this->articleRepository = $articleRepository;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function createNew()
28
    {
29
        return new $this->className();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function createNewWithArticle(string $id): ArticleCommentInterface
36
    {
37
        /** @var ArticleInterface $article */
38
        $article = $this->articleRepository->find($id);
39
40
        if (!$article instanceof ArticleInterface) {
0 ignored issues
show
introduced by
$article is always a sub-type of Odiseo\BlogBundle\Model\ArticleInterface.
Loading history...
41
            throw new Exception();
42
        }
43
44
        /** @var ArticleCommentInterface $articleComment */
45
        $articleComment = $this->createNew();
46
        $articleComment->setArticle($article);
47
48
        return $articleComment;
49
    }
50
}
51