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 ( ac5983...c9485c )
by Odiseo
04:52
created

ArticleRepository::findByCategoryAndChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusBlogPlugin\Doctrine\ORM;
6
7
use Odiseo\BlogBundle\Doctrine\ORM\ArticleRepository as BaseArticleRepository;
8
use Doctrine\ORM\QueryBuilder;
9
use Odiseo\SyliusBlogPlugin\Model\ArticleInterface;
10
use Pagerfanta\Pagerfanta;
11
use Sylius\Component\Core\Model\ChannelInterface;
12
13
class ArticleRepository extends BaseArticleRepository implements ArticleRepositoryInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function createByChannelQueryBuilder(string $channelCode): QueryBuilder
19
    {
20
        return $this->createQueryBuilder('o')
21
            ->innerJoin('o.channels', 'channels')
22
            ->andWhere('o.enabled = true')
23
            ->andWhere('channels.code = :channelCode')
24
            ->addOrderBy('o.createdAt', 'DESC')
25
            ->setParameter('channelCode', $channelCode)
26
        ;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function createByCategoryAndChannelQueryBuilder(string $categorySlug, ?string $localeCode, string $channelCode): QueryBuilder
33
    {
34
        return $this->createByChannelQueryBuilder($channelCode)
35
            ->leftJoin('o.categories', 'category')
36
            ->leftJoin('category.translations', 'categoryTranslation')
37
            ->andWhere('categoryTranslation.locale = :localeCode')
38
            ->andWhere('categoryTranslation.slug = :slug')
39
            ->setParameter('localeCode', $localeCode)
40
            ->setParameter('slug', $categorySlug)
41
        ;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function createByAuthorAndChannelQueryBuilder(ChannelInterface $channel, string $locale, string $authorUsername): QueryBuilder
48
    {
49
        return $this->createByChannelQueryBuilder($channel->getCode())
0 ignored issues
show
Bug introduced by
It seems like $channel->getCode() can also be of type null; however, parameter $channelCode of Odiseo\SyliusBlogPlugin\...ByChannelQueryBuilder() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
        return $this->createByChannelQueryBuilder(/** @scrutinizer ignore-type */ $channel->getCode())
Loading history...
50
            ->addSelect('translation')
51
            ->addSelect('author')
52
            ->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
53
            ->leftJoin('o.author', 'author')
54
            ->andWhere('author.username = :username')
55
            ->addOrderBy('o.createdAt', 'DESC')
56
            ->setParameter('locale', $locale)
57
            ->setParameter('username', $authorUsername)
58
        ;
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function findOneBySlugAndChannel(string $slug, ?string $localeCode, string $channelCode): ?ArticleInterface
65
    {
66
        return $this->createByChannelQueryBuilder($channelCode)
67
            ->leftJoin('o.translations', 'translation')
68
            ->andWhere('translation.locale = :localeCode')
69
            ->andWhere('translation.slug = :slug')
70
            ->setParameter('localeCode', $localeCode)
71
            ->setParameter('slug', $slug)
72
            ->getQuery()
73
            ->getOneOrNullResult()
74
        ;
75
    }
76
77
    /**
78
     * @inheritdoc
79
     */
80
    public function findByChannel(string $channelCode): Pagerfanta
81
    {
82
        return $this->getPaginator($this->createByChannelQueryBuilder($channelCode));
83
    }
84
85
    /**
86
     * @inheritdoc
87
     */
88
    public function findByCategoryAndChannel(string $categorySlug, ?string $localeCode, string $channelCode): Pagerfanta
89
    {
90
        return $this->getPaginator($this->createByCategoryAndChannelQueryBuilder($categorySlug, $localeCode, $channelCode));
91
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96
    public function findByAuthorAndChannel(ChannelInterface $channel, string $locale, string $authorUsername): Pagerfanta
97
    {
98
        return $this->getPaginator($this->createByAuthorAndChannelQueryBuilder($channel, $locale, $authorUsername));
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function findLatestByChannel(ChannelInterface $channel, string $locale, int $count): array
105
    {
106
        return $this->createByChannelQueryBuilder($channel->getCode())
0 ignored issues
show
Bug introduced by
It seems like $channel->getCode() can also be of type null; however, parameter $channelCode of Odiseo\SyliusBlogPlugin\...ByChannelQueryBuilder() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

106
        return $this->createByChannelQueryBuilder(/** @scrutinizer ignore-type */ $channel->getCode())
Loading history...
107
            ->addSelect('translation')
108
            ->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
109
            ->addOrderBy('o.createdAt', 'DESC')
110
            ->setParameter('locale', $locale)
111
            ->setMaxResults($count)
112
            ->getQuery()
113
            ->getResult()
114
        ;
115
    }
116
}
117