• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FastyBird / simple-auth / 10065316629

23 Jul 2024 06:46PM UTC coverage: 63.636% (-5.7%) from 69.347%
10065316629

push

github

web-flow
Trying to fix memory leak (#14)

* Trying to fix memory leak

* Fixing entity mapping

36 of 118 new or added lines in 4 files covered. (30.51%)

10 existing lines in 3 files now uncovered.

539 of 847 relevant lines covered (63.64%)

5.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/src/Queries/FindPolicies.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * FindPolicies.php
5
 *
6
 * @license        More in LICENSE.md
7
 * @copyright      https://www.fastybird.com
8
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
9
 * @package        FastyBird:SimpleAuth!
10
 * @subpackage     Queries
11
 * @since          0.1.0
12
 *
13
 * @date           15.07.24
14
 */
15

16
namespace FastyBird\SimpleAuth\Queries;
17

18
use Closure;
19
use Doctrine\ORM;
20
use FastyBird\SimpleAuth\Entities;
21
use FastyBird\SimpleAuth\Types;
22
use IPub\DoctrineOrmQuery;
23
use Ramsey\Uuid;
24
use function assert;
25

26
/**
27
 * Find tokens entities query
28
 *
29
 * @template T of Entities\Policies\Policy
30
 * @extends  DoctrineOrmQuery\QueryObject<T>
31
 *
32
 * @package          FastyBird:SimpleAuth!
33
 * @subpackage       Queries
34
 * @author           Adam Kadlec <adam.kadlec@fastybird.com>
35
 */
36
class FindPolicies extends DoctrineOrmQuery\QueryObject
37
{
38

39
        /** @var array<Closure(ORM\QueryBuilder $qb): void> */
40
        protected array $filter = [];
41

42
        /** @var array<Closure(ORM\QueryBuilder $qb): void> */
43
        protected array $select = [];
44

45
        public function byId(Uuid\UuidInterface $id): void
46
        {
47
                $this->filter[] = static function (ORM\QueryBuilder $qb) use ($id): void {
6✔
48
                        $qb->andWhere('p.id = :id')->setParameter('id', $id, Uuid\Doctrine\UuidBinaryType::NAME);
6✔
49
                };
6✔
50
        }
51

52
        public function byType(Types\PolicyType $type): void
53
        {
54
                $this->filter[] = static function (ORM\QueryBuilder $qb) use ($type): void {
3✔
55
                        $qb->andWhere('p.type = :type')->setParameter('type', $type);
3✔
56
                };
3✔
57
        }
58

59
        public function byValue(int $key, string|null $value): void
60
        {
61
                assert($key >= 0 && $key <= 5);
62

UNCOV
63
                $this->filter[] = static function (ORM\QueryBuilder $qb) use ($key, $value): void {
×
UNCOV
64
                        $qb->andWhere('p.v' . $key . ' = :v' . $key . 'value')->setParameter('v' . $key . 'value', $value);
×
UNCOV
65
                };
×
66
        }
67

68
        /**
69
         * @param ORM\EntityRepository<T> $repository
70
         */
71
        protected function doCreateQuery(ORM\EntityRepository $repository): ORM\QueryBuilder
72
        {
73
                return $this->createBasicDql($repository);
9✔
74
        }
75

76
        /**
77
         * @param ORM\EntityRepository<T> $repository
78
         */
79
        protected function createBasicDql(ORM\EntityRepository $repository): ORM\QueryBuilder
80
        {
81
                $qb = $repository->createQueryBuilder('p');
9✔
82

83
                foreach ($this->select as $modifier) {
9✔
84
                        $modifier($qb);
×
85
                }
86

87
                foreach ($this->filter as $modifier) {
9✔
88
                        $modifier($qb);
9✔
89
                }
90

91
                return $qb;
9✔
92
        }
93

94
        /**
95
         * @param ORM\EntityRepository<T> $repository
96
         */
97
        protected function doCreateCountQuery(ORM\EntityRepository $repository): ORM\QueryBuilder
98
        {
99
                return $this->createBasicDql($repository)->select('COUNT(p.id)');
×
100
        }
101

102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc