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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createNewWithArticle() 0 14 2
A __construct() 0 4 1
A createNew() 0 3 1
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