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

valkyrjaio / valkyrja / 20687263522

04 Jan 2026 03:56AM UTC coverage: 74.209%. Remained the same
20687263522

push

github

web-flow
[CI] Add dead code rector rules (#337)

# Description

Add dead code rector rules.

## Types of changes

- [ ] Bug fix _(non-breaking change which fixes an issue)_
    <!-- Target the lowest major affected branch -->
- [X] New feature _(non-breaking change which adds functionality)_
    <!-- Target master -->
- [ ] Deprecation _(breaking change which removes functionality)_
    <!-- Target master -->
- [ ] Breaking change _(fix or feature that would cause existing
functionality
  to change)_
<!-- Target master, unless this is a bug fix in which case let's chat
-->
- [ ] Documentation improvement
    <!-- Target appropriate branch -->

8419 of 11345 relevant lines covered (74.21%)

8.87 hits per line

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

0.0
/src/Valkyrja/Orm/QueryBuilder/SqlSelectQueryBuilder.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <melechmizrachi@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Valkyrja\Orm\QueryBuilder;
15

16
use Override;
17
use Valkyrja\Orm\Constant\Statement;
18
use Valkyrja\Orm\Data\OrderBy;
19
use Valkyrja\Orm\QueryBuilder\Abstract\SqlQueryBuilder;
20
use Valkyrja\Orm\QueryBuilder\Contract\SelectQueryBuilderContract as Contract;
21

22
class SqlSelectQueryBuilder extends SqlQueryBuilder implements Contract
23
{
24
    /** @var non-empty-string[] */
25
    protected array $columns = ['*'];
26
    /** @var string[] */
27
    protected array $groupBy = [];
28
    /** @var OrderBy[] */
29
    protected array $orderBy = [];
30
    /** @var int|null */
31
    protected int|null $limit = null;
32
    /** @var int|null */
33
    protected int|null $offset = null;
34

35
    /**
36
     * @inheritDoc
37
     */
38
    #[Override]
×
39
    public function withColumns(string ...$columns): static
40
    {
41
        $new = clone $this;
×
42

43
        $new->columns = $columns;
×
44

45
        return $new;
×
46
    }
47

48
    /**
49
     * @inheritDoc
50
     */
51
    #[Override]
×
52
    public function withAddedColumns(string ...$columns): static
53
    {
54
        $new = clone $this;
×
55

56
        $new->columns = array_merge($new->columns, $columns);
×
57

58
        return $new;
×
59
    }
60

61
    /**
62
     * @inheritDoc
63
     */
64
    #[Override]
×
65
    public function withGroupBy(string ...$groupBy): static
66
    {
67
        $new = clone $this;
×
68

69
        $new->groupBy = $groupBy;
×
70

71
        return $new;
×
72
    }
73

74
    /**
75
     * @inheritDoc
76
     */
77
    #[Override]
×
78
    public function withAddedGroupBy(string ...$groupBy): static
79
    {
80
        $new = clone $this;
×
81

82
        $new->groupBy = array_merge($new->groupBy, $groupBy);
×
83

84
        return $new;
×
85
    }
86

87
    /**
88
     * @inheritDoc
89
     */
90
    #[Override]
×
91
    public function withOrderBy(OrderBy ...$orderBy): static
92
    {
93
        $new = clone $this;
×
94

95
        $new->orderBy = $orderBy;
×
96

97
        return $new;
×
98
    }
99

100
    /**
101
     * @inheritDoc
102
     */
103
    #[Override]
×
104
    public function withAddedOrderBy(OrderBy ...$orderBy): static
105
    {
106
        $new = clone $this;
×
107

108
        $new->orderBy = array_merge($new->orderBy, $orderBy);
×
109

110
        return $new;
×
111
    }
112

113
    /**
114
     * @inheritDoc
115
     */
116
    #[Override]
×
117
    public function withLimit(int $limit): static
118
    {
119
        $new = clone $this;
×
120

121
        $new->limit = $limit;
×
122

123
        return $new;
×
124
    }
125

126
    /**
127
     * @inheritDoc
128
     */
129
    #[Override]
×
130
    public function withOffset(int $offset): static
131
    {
132
        $new = clone $this;
×
133

134
        $new->offset = $offset;
×
135

136
        return $new;
×
137
    }
138

139
    /**
140
     * @inheritDoc
141
     */
142
    public function __toString(): string
×
143
    {
144
        return Statement::SELECT
×
145
            . ' ' . implode(', ', $this->columns)
×
146
            . ' ' . Statement::FROM
×
147
            . " $this->from"
×
148
            . $this->getJoinQuery()
×
149
            . $this->getWhereQuery()
×
150
            . $this->getGroupByQuery()
×
151
            . $this->getOrderByQuery()
×
152
            . $this->getLimitQuery()
×
153
            . $this->getOffsetQuery();
×
154
    }
155

156
    /**
157
     * Get the GROUP BY part of a query statement.
158
     */
159
    protected function getGroupByQuery(): string
×
160
    {
161
        return empty($this->orderBy) || $this->isCount()
×
162
            ? ''
×
163
            : ' ' . Statement::GROUP_BY . ' ' . implode(', ', $this->groupBy);
×
164
    }
165

166
    /**
167
     * Get the ORDER BY part of a query statement.
168
     */
169
    protected function getOrderByQuery(): string
×
170
    {
171
        return empty($this->orderBy) || $this->isCount()
×
172
            ? ''
×
173
            : ' ' . Statement::ORDER_BY . ' ' . implode(', ', $this->orderBy);
×
174
    }
175

176
    /**
177
     * Get the LIMIT part of a query statement.
178
     */
179
    protected function getLimitQuery(): string
×
180
    {
181
        return $this->limit === null || $this->isCount()
×
182
            ? ''
×
183
            : ' ' . Statement::LIMIT . ' ' . ((string) $this->limit);
×
184
    }
185

186
    /**
187
     * Get the OFFSET part of a query statement.
188
     */
189
    protected function getOffsetQuery(): string
×
190
    {
191
        return $this->offset === null || $this->isCount()
×
192
            ? ''
×
193
            : ' ' . Statement::OFFSET . ' ' . ((string) $this->offset);
×
194
    }
195

196
    /**
197
     * Determine whether this is a count statement.
198
     */
199
    protected function isCount(): bool
×
200
    {
201
        return str_starts_with($this->columns[0], 'COUNT');
×
202
    }
203
}
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