SiteSettingRepository::findBySiteId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 4
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Entity;
4
5
class SiteSettingRepository extends EntityRepository
6
{
7
    /**
8
     * @param int    $siteId
9
     * @param string $setting
10
     *
11
     * @return SiteSetting|null
12
     */
13
    public function findBySiteIdAndSetting(int $siteId, string $setting): ?SiteSetting
14
    {
15
        /** @var SiteSetting $obj */
16
        $obj = $this->findOneBy([
17
            'siteId' => $siteId,
18
            'setting' => $setting,
19
        ]);
20
21
        return $obj;
22
    }
23
24
    /**
25
     * @param int        $siteId
26
     * @param array|null $orderBy
27
     * @param int|null   $limit
28
     * @param int|null   $offset
29
     *
30
     * @return SiteSetting[]|null
31
     */
32
    public function findBySiteId(int $siteId, array $orderBy = null, int $limit = null, int $offset = null): ?array
33
    {
34
        /** @var SiteSetting[] $objs */
35
        $objs = $this->findBy([
36
            'siteId' => $siteId,
37
        ], $orderBy, $limit, $offset);
0 ignored issues
show
Bug introduced by
It seems like $orderBy defined by parameter $orderBy on line 32 can also be of type null; however, Loevgaard\DandomainAltap...ityRepository::findBy() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
38
39
        return $objs;
40
    }
41
42
    /**
43
     * Usage:
44
     * $collection = SiteSettingRepository::findBySiteIdIndexedBySetting($siteId)
45
     * echo $collection['setting']->getVal();.
46
     *
47
     * @param int $siteId
48
     *
49
     * @return SiteSetting[]|null
50
     */
51
    public function findBySiteIdIndexedBySetting(int $siteId): ?array
52
    {
53
        $qb = $this->getQueryBuilder('s');
54
        $qb
55
            ->where($qb->expr()->eq('s.siteId', $siteId))
56
            ->indexBy('s', 's.setting')
57
        ;
58
59
        return $qb->getQuery()->getResult();
60
    }
61
62
    /**
63
     * @param string     $setting
64
     * @param array|null $orderBy
65
     * @param int|null   $limit
66
     * @param int|null   $offset
67
     *
68
     * @return SiteSetting[]|null
69
     */
70
    public function findBySetting(string $setting, array $orderBy = null, int $limit = null, int $offset = null): ?array
71
    {
72
        /** @var SiteSetting[] $objs */
73
        $objs = $this->findBy([
74
            'setting' => $setting,
75
        ], $orderBy, $limit, $offset);
0 ignored issues
show
Bug introduced by
It seems like $orderBy defined by parameter $orderBy on line 70 can also be of type null; however, Loevgaard\DandomainAltap...ityRepository::findBy() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
76
77
        return $objs;
78
    }
79
}
80