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.

createNewWithArticleOrComment()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 10
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusBlogPlugin\Factory;
6
7
use Odiseo\BlogBundle\Factory\ArticleCommentFactoryInterface;
8
use Odiseo\BlogBundle\Model\ArticleCommentInterface;
9
use Sylius\Component\Core\Model\ShopUserInterface;
10
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
11
12
final class ArticleCommentFactory implements ArticleCommentFactoryInterface
13
{
14
    /** @var ArticleCommentFactoryInterface  */
15
    private $decoratedFactory;
16
17
    /** @var ShopUserInterface|object|string|null */
18
    private $shopUser;
19
20
    public function __construct(
21
        ArticleCommentFactoryInterface $decoratedFactory,
22
        TokenStorageInterface $tokenStorage
23
    ) {
24
        $this->decoratedFactory = $decoratedFactory;
25
26
        $token = $tokenStorage->getToken();
27
        $this->shopUser = $token !== null ? $token->getUser() : null;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function createNew(): object
34
    {
35
        return $this->decoratedFactory->createNew();
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function createNewWithArticleOrComment(string $articleId, string $commentId = null): ArticleCommentInterface
42
    {
43
        /** @var \Odiseo\SyliusBlogPlugin\Entity\ArticleCommentInterface $articleComment */
44
        $articleComment = $this->decoratedFactory->createNewWithArticleOrComment($articleId, $commentId);
45
46
        if ($this->shopUser instanceof ShopUserInterface) {
47
            $articleComment->setAuthor($this->shopUser);
48
        }
49
50
        return $articleComment;
51
    }
52
}
53