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

brick / orm / 23255296146

18 Mar 2026 04:24PM UTC coverage: 47.104%. Remained the same
23255296146

push

github

BenMorel
Avoid \Exception that somehow confuses ECS

1 of 5 new or added lines in 1 file covered. (20.0%)

402 existing lines in 24 files now uncovered.

553 of 1174 relevant lines covered (47.1%)

10.6 hits per line

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

62.5
/src/Query.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Brick\ORM;
6

7
use InvalidArgumentException;
8

9
use function array_values;
10

11
class Query
12
{
13
    /**
14
     * @var class-string
15
     */
16
    private string $className;
17

18
    /**
19
     * The properties to load, or null to load the full entity.
20
     *
21
     * @var list<string>|null
22
     */
23
    private ?array $properties = null;
24

25
    /**
26
     * @var list<QueryPredicate>
27
     */
28
    private array $predicates = [];
29

30
    /**
31
     * @var list<QueryOrderBy>
32
     */
33
    private array $orderBy = [];
34

35
    private ?int $limit = null;
36

37
    private ?int $offset = null;
38

39
    /**
40
     * @param class-string $className
41
     */
42
    public function __construct(string $className)
43
    {
44
        $this->className = $className;
64✔
45
    }
46

47
    public function setProperties(string ...$properties): Query
48
    {
49
        $this->properties = array_values($properties);
6✔
50

51
        return $this;
6✔
52
    }
53

54
    /**
55
     * @throws InvalidArgumentException If the operator is invalid.
56
     */
57
    public function addPredicate(string $property, string $operator, mixed $value): Query
58
    {
59
        $this->predicates[] = new QueryPredicate($property, $operator, $value);
64✔
60

61
        return $this;
64✔
62
    }
63

64
    /**
65
     * @param string $property  The property to order by.
66
     * @param string $direction The order direction, 'ASC' or 'DESC'.
67
     *
68
     * @throws InvalidArgumentException If the order direction is invalid.
69
     */
70
    public function addOrderBy(string $property, string $direction = 'ASC'): Query
71
    {
UNCOV
72
        $this->orderBy[] = new QueryOrderBy($property, $direction);
×
73

74
        return $this;
×
75
    }
76

77
    public function setLimit(int $limit, int $offset = 0): Query
78
    {
UNCOV
79
        $this->limit = $limit;
×
UNCOV
80
        $this->offset = $offset;
×
81

82
        return $this;
×
83
    }
84

85
    /**
86
     * @return class-string
87
     */
88
    public function getClassName(): string
89
    {
90
        return $this->className;
64✔
91
    }
92

93
    /**
94
     * @return list<string>|null
95
     */
96
    public function getProperties(): ?array
97
    {
98
        return $this->properties;
64✔
99
    }
100

101
    /**
102
     * @return list<QueryPredicate>
103
     */
104
    public function getPredicates(): array
105
    {
106
        return $this->predicates;
63✔
107
    }
108

109
    /**
110
     * @return list<QueryOrderBy>
111
     */
112
    public function getOrderBy(): array
113
    {
114
        return $this->orderBy;
63✔
115
    }
116

117
    public function getLimit(): ?int
118
    {
119
        return $this->limit;
63✔
120
    }
121

122
    public function getOffset(): ?int
123
    {
UNCOV
124
        return $this->offset;
×
125
    }
126
}
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