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.

VendorRepository::findOneBySlug()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 10
nc 1
nop 2
dl 0
loc 12
rs 9.9332
c 1
b 1
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Odiseo\SyliusVendorPlugin\Repository;
6
7
use Doctrine\ORM\QueryBuilder;
8
use Odiseo\SyliusVendorPlugin\Entity\VendorInterface;
9
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
10
use Sylius\Component\Core\Model\ChannelInterface;
11
12
class VendorRepository extends EntityRepository implements VendorRepositoryInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function createShopListQueryBuilder(
18
        ChannelInterface $channel,
19
        array $sorting = []
20
    ): QueryBuilder {
21
        return $this->findByEnabledQueryBuilder($channel);
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function findByEnabledQueryBuilder(?ChannelInterface $channel): QueryBuilder
28
    {
29
        $queryBuilder = $this->createQueryBuilder('o')
30
            ->andWhere('o.enabled = :enabled')
31
            ->setParameter('enabled', true)
32
        ;
33
34
        if ($channel instanceof ChannelInterface) {
35
            $queryBuilder->innerJoin('o.channels', 'channel')
36
                ->andWhere('channel = :channel')
37
                ->setParameter('channel', $channel)
38
            ;
39
        }
40
41
        return $queryBuilder;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function findByChannel(ChannelInterface $channel): array
48
    {
49
        return $this->findByEnabledQueryBuilder($channel)->getQuery()->getResult();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->findByEnab...getQuery()->getResult() could return the type integer which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function findOneBySlug(string $slug, string $locale): ?VendorInterface
56
    {
57
        return $this->createQueryBuilder('o')
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->createQuer...)->getOneOrNullResult() could return the type integer which is incompatible with the type-hinted return Odiseo\SyliusVendorPlugi...ty\VendorInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
58
            ->addSelect('translation')
59
            ->innerJoin('o.translations', 'translation')
60
            ->andWhere('o.slug = :slug')
61
            ->andWhere('o.enabled = true')
62
            ->andWhere('translation.locale = :locale')
63
            ->setParameter('slug', $slug)
64
            ->setParameter('locale', $locale)
65
            ->getQuery()
66
            ->getOneOrNullResult()
67
        ;
68
    }
69
}
70