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

FastyBird / simple-auth / 7822099561

07 Feb 2024 10:39PM UTC coverage: 74.633% (-3.5%) from 78.119%
7822099561

push

github

akadlec
Use native enum

3 of 7 new or added lines in 3 files covered. (42.86%)

29 existing lines in 5 files now uncovered.

356 of 477 relevant lines covered (74.63%)

4.91 hits per line

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

52.94
/src/Queries/FindTokens.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * FindTokens.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           31.03.20
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

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

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

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

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

51
        public function byToken(string $token): void
52
        {
53
                $this->filter[] = static function (ORM\QueryBuilder $qb) use ($token): void {
3✔
54
                        $qb->andWhere('t.token = :token')->setParameter('token', $token);
3✔
55
                };
3✔
56
        }
57

58
        public function inState(Types\TokenState $state): void
59
        {
60
                $this->filter[] = static function (ORM\QueryBuilder $qb) use ($state): void {
×
NEW
61
                        $qb->andWhere('t.state = :state')->setParameter('state', $state->value);
×
62
                };
×
63
        }
64

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

73
        /**
74
         * @param ORM\EntityRepository<T> $repository
75
         */
76
        private function createBasicDql(ORM\EntityRepository $repository): ORM\QueryBuilder
77
        {
78
                $qb = $repository->createQueryBuilder('t');
3✔
79

80
                foreach ($this->select as $modifier) {
3✔
81
                        $modifier($qb);
×
82
                }
83

84
                foreach ($this->filter as $modifier) {
3✔
85
                        $modifier($qb);
3✔
86
                }
87

88
                return $qb;
3✔
89
        }
90

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

99
}
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