Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
34 / 34 |
|
100.00% |
34 / 34 |
CRAP | |
100.00% |
1 / 1 |
| Having | |
100.00% |
34 / 34 |
|
100.00% |
34 / 34 |
34 | |
100.00% |
1 / 1 |
| having | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHaving | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingNotEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingNotEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingNullSafeEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingNullSafeEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingLessThan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingLessThan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingLessThanOrEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingLessThanOrEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingGreaterThan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingGreaterThan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingGreaterThanOrEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingGreaterThanOrEqual | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingLike | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingLike | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingNotLike | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingNotLike | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingIn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingIn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingNotIn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingNotIn | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingBetween | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingBetween | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingNotBetween | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingNotBetween | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingIsNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingIsNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| havingIsNotNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| orHavingIsNotNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addHaving | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| renderHaving | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of Aplus Framework Database Library. |
| 4 | * |
| 5 | * (c) Natan Felles <natanfelles@gmail.com> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace Framework\Database\Manipulation\Traits; |
| 11 | |
| 12 | use Closure; |
| 13 | |
| 14 | /** |
| 15 | * Trait Having. |
| 16 | * |
| 17 | * @package database |
| 18 | */ |
| 19 | trait Having |
| 20 | { |
| 21 | use Where; |
| 22 | |
| 23 | /** |
| 24 | * Appends an "AND $column $operator ...$values" condition in the HAVING clause. |
| 25 | * |
| 26 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 27 | * @param string $operator |
| 28 | * @param Closure|float|int|string|null ...$values |
| 29 | * |
| 30 | * @return static |
| 31 | */ |
| 32 | public function having( |
| 33 | Closure | string $column, |
| 34 | string $operator, |
| 35 | Closure | float | int | string | null ...$values |
| 36 | ) : static { |
| 37 | return $this->addHaving('AND', $column, $operator, $values); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Appends a "OR $column $operator ...$values" condition in the HAVING clause. |
| 42 | * |
| 43 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 44 | * @param string $operator |
| 45 | * @param Closure|float|int|string|null ...$values |
| 46 | * |
| 47 | * @return static |
| 48 | */ |
| 49 | public function orHaving( |
| 50 | Closure | string $column, |
| 51 | string $operator, |
| 52 | Closure | float | int | string | null ...$values |
| 53 | ) : static { |
| 54 | return $this->addHaving('OR', $column, $operator, $values); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Appends an "AND $column = $value" condition in the HAVING clause. |
| 59 | * |
| 60 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 61 | * @param Closure|float|int|string|null $value |
| 62 | * |
| 63 | * @see https://mariadb.com/kb/en/equal/ |
| 64 | * |
| 65 | * @return static |
| 66 | */ |
| 67 | public function havingEqual( |
| 68 | Closure | string $column, |
| 69 | Closure | float | int | string | null $value |
| 70 | ) : static { |
| 71 | return $this->having($column, '=', $value); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Appends a "OR $column = $value" condition in the HAVING clause. |
| 76 | * |
| 77 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 78 | * @param Closure|float|int|string|null $value |
| 79 | * |
| 80 | * @see https://mariadb.com/kb/en/equal/ |
| 81 | * |
| 82 | * @return static |
| 83 | */ |
| 84 | public function orHavingEqual( |
| 85 | Closure | string $column, |
| 86 | Closure | float | int | string | null $value |
| 87 | ) : static { |
| 88 | return $this->orHaving($column, '=', $value); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Appends an "AND $column != $value" condition in the HAVING clause. |
| 93 | * |
| 94 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 95 | * @param Closure|float|int|string|null $value |
| 96 | * |
| 97 | * @see https://mariadb.com/kb/en/not-equal/ |
| 98 | * |
| 99 | * @return static |
| 100 | */ |
| 101 | public function havingNotEqual( |
| 102 | Closure | string $column, |
| 103 | Closure | float | int | string | null $value |
| 104 | ) : static { |
| 105 | return $this->having($column, '!=', $value); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Appends a "OR $column != $value" condition in the HAVING clause. |
| 110 | * |
| 111 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 112 | * @param Closure|float|int|string|null $value |
| 113 | * |
| 114 | * @see https://mariadb.com/kb/en/not-equal/ |
| 115 | * |
| 116 | * @return static |
| 117 | */ |
| 118 | public function orHavingNotEqual( |
| 119 | Closure | string $column, |
| 120 | Closure | float | int | string | null $value |
| 121 | ) : static { |
| 122 | return $this->orHaving($column, '!=', $value); |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Appends an "AND $column <=> $value" condition in the HAVING clause. |
| 127 | * |
| 128 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 129 | * @param Closure|float|int|string|null $value |
| 130 | * |
| 131 | * @see https://mariadb.com/kb/en/null-safe-equal/ |
| 132 | * |
| 133 | * @return static |
| 134 | */ |
| 135 | public function havingNullSafeEqual( |
| 136 | Closure | string $column, |
| 137 | Closure | float | int | string | null $value |
| 138 | ) : static { |
| 139 | return $this->having($column, '<=>', $value); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Appends a "OR $column <=> $value" condition in the HAVING clause. |
| 144 | * |
| 145 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 146 | * @param Closure|float|int|string|null $value |
| 147 | * |
| 148 | * @see https://mariadb.com/kb/en/null-safe-equal/ |
| 149 | * |
| 150 | * @return static |
| 151 | */ |
| 152 | public function orHavingNullSafeEqual( |
| 153 | Closure | string $column, |
| 154 | Closure | float | int | string | null $value |
| 155 | ) : static { |
| 156 | return $this->orHaving($column, '<=>', $value); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Appends an "AND $column < $value" condition in the HAVING clause. |
| 161 | * |
| 162 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 163 | * @param Closure|float|int|string|null $value |
| 164 | * |
| 165 | * @see https://mariadb.com/kb/en/less-than/ |
| 166 | * |
| 167 | * @return static |
| 168 | */ |
| 169 | public function havingLessThan( |
| 170 | Closure | string $column, |
| 171 | Closure | float | int | string | null $value |
| 172 | ) : static { |
| 173 | return $this->having($column, '<', $value); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * Appends a "OR $column < $value" condition in the HAVING clause. |
| 178 | * |
| 179 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 180 | * @param Closure|float|int|string|null $value |
| 181 | * |
| 182 | * @see https://mariadb.com/kb/en/less-than/ |
| 183 | * |
| 184 | * @return static |
| 185 | */ |
| 186 | public function orHavingLessThan( |
| 187 | Closure | string $column, |
| 188 | Closure | float | int | string | null $value |
| 189 | ) : static { |
| 190 | return $this->orHaving($column, '<', $value); |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Appends an "AND $column <= $value" condition in the HAVING clause. |
| 195 | * |
| 196 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 197 | * @param Closure|float|int|string|null $value |
| 198 | * |
| 199 | * @see https://mariadb.com/kb/en/less-than-or-equal/ |
| 200 | * |
| 201 | * @return static |
| 202 | */ |
| 203 | public function havingLessThanOrEqual( |
| 204 | Closure | string $column, |
| 205 | Closure | float | int | string | null $value |
| 206 | ) : static { |
| 207 | return $this->having($column, '<=', $value); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * Appends a "OR $column <= $value" condition in the HAVING clause. |
| 212 | * |
| 213 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 214 | * @param Closure|float|int|string|null $value |
| 215 | * |
| 216 | * @see https://mariadb.com/kb/en/less-than-or-equal/ |
| 217 | * |
| 218 | * @return static |
| 219 | */ |
| 220 | public function orHavingLessThanOrEqual( |
| 221 | Closure | string $column, |
| 222 | Closure | float | int | string | null $value |
| 223 | ) : static { |
| 224 | return $this->orHaving($column, '<=', $value); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Appends an "AND $column > $value" condition in the HAVING clause. |
| 229 | * |
| 230 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 231 | * @param Closure|float|int|string|null $value |
| 232 | * |
| 233 | * @see https://mariadb.com/kb/en/greater-than/ |
| 234 | * |
| 235 | * @return static |
| 236 | */ |
| 237 | public function havingGreaterThan( |
| 238 | Closure | string $column, |
| 239 | Closure | float | int | string | null $value |
| 240 | ) : static { |
| 241 | return $this->having($column, '>', $value); |
| 242 | } |
| 243 | |
| 244 | /** |
| 245 | * Appends a "OR $column > $value" condition in the HAVING clause. |
| 246 | * |
| 247 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 248 | * @param Closure|float|int|string|null $value |
| 249 | * |
| 250 | * @see https://mariadb.com/kb/en/greater-than/ |
| 251 | * |
| 252 | * @return static |
| 253 | */ |
| 254 | public function orHavingGreaterThan( |
| 255 | Closure | string $column, |
| 256 | Closure | float | int | string | null $value |
| 257 | ) : static { |
| 258 | return $this->orHaving($column, '>', $value); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Appends an "AND $column >= $value" condition in the HAVING clause. |
| 263 | * |
| 264 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 265 | * @param Closure|float|int|string|null $value |
| 266 | * |
| 267 | * @see https://mariadb.com/kb/en/greater-than-or-equal/ |
| 268 | * |
| 269 | * @return static |
| 270 | */ |
| 271 | public function havingGreaterThanOrEqual( |
| 272 | Closure | string $column, |
| 273 | Closure | float | int | string | null $value |
| 274 | ) : static { |
| 275 | return $this->having($column, '>=', $value); |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * Appends a "OR $column >= $value" condition in the HAVING clause. |
| 280 | * |
| 281 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 282 | * @param Closure|float|int|string|null $value |
| 283 | * |
| 284 | * @see https://mariadb.com/kb/en/greater-than-or-equal/ |
| 285 | * |
| 286 | * @return static |
| 287 | */ |
| 288 | public function orHavingGreaterThanOrEqual( |
| 289 | Closure | string $column, |
| 290 | Closure | float | int | string | null $value |
| 291 | ) : static { |
| 292 | return $this->orHaving($column, '>=', $value); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Appends an "AND $column LIKE $value" condition in the HAVING clause. |
| 297 | * |
| 298 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 299 | * @param Closure|float|int|string|null $value |
| 300 | * |
| 301 | * @see https://mariadb.com/kb/en/like/ |
| 302 | * |
| 303 | * @return static |
| 304 | */ |
| 305 | public function havingLike( |
| 306 | Closure | string $column, |
| 307 | Closure | float | int | string | null $value |
| 308 | ) : static { |
| 309 | return $this->having($column, 'LIKE', $value); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * Appends a "OR $column LIKE $value" condition in the HAVING clause. |
| 314 | * |
| 315 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 316 | * @param Closure|float|int|string|null $value |
| 317 | * |
| 318 | * @see https://mariadb.com/kb/en/like/ |
| 319 | * |
| 320 | * @return static |
| 321 | */ |
| 322 | public function orHavingLike( |
| 323 | Closure | string $column, |
| 324 | Closure | float | int | string | null $value |
| 325 | ) : static { |
| 326 | return $this->orHaving($column, 'LIKE', $value); |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * Appends an "AND $column NOT LIKE" $value condition. |
| 331 | * |
| 332 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 333 | * @param Closure|float|int|string|null $value |
| 334 | * |
| 335 | * @see https://mariadb.com/kb/en/not-like/ |
| 336 | * |
| 337 | * @return static |
| 338 | */ |
| 339 | public function havingNotLike( |
| 340 | Closure | string $column, |
| 341 | Closure | float | int | string | null $value |
| 342 | ) : static { |
| 343 | return $this->having($column, 'NOT LIKE', $value); |
| 344 | } |
| 345 | |
| 346 | /** |
| 347 | * Appends a "OR $column NOT LIKE $value" condition in the HAVING clause. |
| 348 | * |
| 349 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 350 | * @param Closure|float|int|string|null $value |
| 351 | * |
| 352 | * @see https://mariadb.com/kb/en/not-like/ |
| 353 | * |
| 354 | * @return static |
| 355 | */ |
| 356 | public function orHavingNotLike( |
| 357 | Closure | string $column, |
| 358 | Closure | float | int | string | null $value |
| 359 | ) : static { |
| 360 | return $this->orHaving($column, 'NOT LIKE', $value); |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Appends an "AND $column IN (...$values)" condition in the HAVING clause. |
| 365 | * |
| 366 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 367 | * @param Closure|float|int|string|null $value |
| 368 | * @param Closure|float|int|string|null ...$values |
| 369 | * |
| 370 | * @see https://mariadb.com/kb/en/in/ |
| 371 | * |
| 372 | * @return static |
| 373 | */ |
| 374 | public function havingIn( |
| 375 | Closure | string $column, |
| 376 | Closure | float | int | string | null $value, |
| 377 | Closure | float | int | string | null ...$values |
| 378 | ) : static { |
| 379 | return $this->having($column, 'IN', ...[$value, ...$values]); |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * Appends a "OR $column IN (...$values)" condition in the HAVING clause. |
| 384 | * |
| 385 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 386 | * @param Closure|float|int|string|null $value |
| 387 | * @param Closure|float|int|string|null ...$values |
| 388 | * |
| 389 | * @see https://mariadb.com/kb/en/in/ |
| 390 | * |
| 391 | * @return static |
| 392 | */ |
| 393 | public function orHavingIn( |
| 394 | Closure | string $column, |
| 395 | Closure | float | int | string | null $value, |
| 396 | Closure | float | int | string | null ...$values |
| 397 | ) : static { |
| 398 | return $this->orHaving($column, 'IN', ...[$value, ...$values]); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Appends an "AND $column NOT IN (...$values)" condition in the HAVING clause. |
| 403 | * |
| 404 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 405 | * @param Closure|float|int|string|null $value |
| 406 | * @param Closure|float|int|string|null ...$values |
| 407 | * |
| 408 | * @see https://mariadb.com/kb/en/not-in/ |
| 409 | * |
| 410 | * @return static |
| 411 | */ |
| 412 | public function havingNotIn( |
| 413 | Closure | string $column, |
| 414 | Closure | float | int | string | null $value, |
| 415 | Closure | float | int | string | null ...$values |
| 416 | ) : static { |
| 417 | return $this->having($column, 'NOT IN', ...[$value, ...$values]); |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Appends a "OR $column NOT IN (...$values)" condition in the HAVING clause. |
| 422 | * |
| 423 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 424 | * @param Closure|float|int|string|null $value |
| 425 | * @param Closure|float|int|string|null ...$values |
| 426 | * |
| 427 | * @see https://mariadb.com/kb/en/not-in/ |
| 428 | * |
| 429 | * @return static |
| 430 | */ |
| 431 | public function orHavingNotIn( |
| 432 | Closure | string $column, |
| 433 | Closure | float | int | string | null $value, |
| 434 | Closure | float | int | string | null ...$values |
| 435 | ) : static { |
| 436 | return $this->orHaving($column, 'NOT IN', ...[$value, ...$values]); |
| 437 | } |
| 438 | |
| 439 | /** |
| 440 | * Appends an "AND $column BETWEEN $min AND $max" condition in the HAVING clause. |
| 441 | * |
| 442 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 443 | * @param Closure|float|int|string|null $min |
| 444 | * @param Closure|float|int|string|null $max |
| 445 | * |
| 446 | * @see https://mariadb.com/kb/en/between-and/ |
| 447 | * |
| 448 | * @return static |
| 449 | */ |
| 450 | public function havingBetween( |
| 451 | Closure | string $column, |
| 452 | Closure | float | int | string | null $min, |
| 453 | Closure | float | int | string | null $max |
| 454 | ) : static { |
| 455 | return $this->having($column, 'BETWEEN', $min, $max); |
| 456 | } |
| 457 | |
| 458 | /** |
| 459 | * Appends a "OR $column BETWEEN $min AND $max" condition in the HAVING clause. |
| 460 | * |
| 461 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 462 | * @param Closure|float|int|string|null $min |
| 463 | * @param Closure|float|int|string|null $max |
| 464 | * |
| 465 | * @see https://mariadb.com/kb/en/between-and/ |
| 466 | * |
| 467 | * @return static |
| 468 | */ |
| 469 | public function orHavingBetween( |
| 470 | Closure | string $column, |
| 471 | Closure | float | int | string | null $min, |
| 472 | Closure | float | int | string | null $max |
| 473 | ) : static { |
| 474 | return $this->orHaving($column, 'BETWEEN', $min, $max); |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Appends an "AND $column NOT BETWEEN $min AND $max" condition in the HAVING clause. |
| 479 | * |
| 480 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 481 | * @param Closure|float|int|string|null $min |
| 482 | * @param Closure|float|int|string|null $max |
| 483 | * |
| 484 | * @see https://mariadb.com/kb/en/not-between/ |
| 485 | * |
| 486 | * @return static |
| 487 | */ |
| 488 | public function havingNotBetween( |
| 489 | Closure | string $column, |
| 490 | Closure | float | int | string | null $min, |
| 491 | Closure | float | int | string | null $max |
| 492 | ) : static { |
| 493 | return $this->having($column, 'NOT BETWEEN', $min, $max); |
| 494 | } |
| 495 | |
| 496 | /** |
| 497 | * Appends a "OR $column NOT BETWEEN $min AND $max" condition in the HAVING clause. |
| 498 | * |
| 499 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 500 | * @param Closure|float|int|string|null $min |
| 501 | * @param Closure|float|int|string|null $max |
| 502 | * |
| 503 | * @see https://mariadb.com/kb/en/not-between/ |
| 504 | * |
| 505 | * @return static |
| 506 | */ |
| 507 | public function orHavingNotBetween( |
| 508 | Closure | string $column, |
| 509 | Closure | float | int | string | null $min, |
| 510 | Closure | float | int | string | null $max |
| 511 | ) : static { |
| 512 | return $this->orHaving($column, 'NOT BETWEEN', $min, $max); |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * Appends an "AND $column IS NULL" condition in the HAVING clause. |
| 517 | * |
| 518 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 519 | * |
| 520 | * @see https://mariadb.com/kb/en/is-null/ |
| 521 | * |
| 522 | * @return static |
| 523 | */ |
| 524 | public function havingIsNull(Closure | string $column) : static |
| 525 | { |
| 526 | return $this->having($column, 'IS NULL'); |
| 527 | } |
| 528 | |
| 529 | /** |
| 530 | * Appends a "OR $column IS NULL" condition in the HAVING clause. |
| 531 | * |
| 532 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 533 | * |
| 534 | * @see https://mariadb.com/kb/en/is-null/ |
| 535 | * |
| 536 | * @return static |
| 537 | */ |
| 538 | public function orHavingIsNull(Closure | string $column) : static |
| 539 | { |
| 540 | return $this->orHaving($column, 'IS NULL'); |
| 541 | } |
| 542 | |
| 543 | /** |
| 544 | * Appends an "AND $column IS NOT NULL" condition in the HAVING clause. |
| 545 | * |
| 546 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 547 | * |
| 548 | * @see https://mariadb.com/kb/en/is-not-null/ |
| 549 | * |
| 550 | * @return static |
| 551 | */ |
| 552 | public function havingIsNotNull(Closure | string $column) : static |
| 553 | { |
| 554 | return $this->having($column, 'IS NOT NULL'); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Appends a "OR $column IS NOT NULL" condition in the HAVING clause. |
| 559 | * |
| 560 | * @param Closure|string $column Closure for a subquery or a string with the column name |
| 561 | * |
| 562 | * @see https://mariadb.com/kb/en/is-not-null/ |
| 563 | * |
| 564 | * @return static |
| 565 | */ |
| 566 | public function orHavingIsNotNull(Closure | string $column) : static |
| 567 | { |
| 568 | return $this->orHaving($column, 'IS NOT NULL'); |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Adds a HAVING part. |
| 573 | * |
| 574 | * @param string $glue `AND` or `OR` |
| 575 | * @param array<array<mixed>|Closure|string>|Closure|string $column |
| 576 | * @param string $operator `=`, `<=>`, `!=`, `<>`, `>`, `>=`, `<`, `<=`, |
| 577 | * `LIKE`, `NOT LIKE`, `IN`, `NOT IN`, `BETWEEN`, `NOT BETWEEN`, `IS NULL`, |
| 578 | * `IS NOT NULL` or `MATCH` |
| 579 | * @param array<Closure|float|int|string|null> $values Values used by the operator |
| 580 | * |
| 581 | * @return static |
| 582 | */ |
| 583 | private function addHaving( |
| 584 | string $glue, |
| 585 | array | Closure | string $column, |
| 586 | string $operator, |
| 587 | array $values |
| 588 | ) : static { |
| 589 | return $this->addWhere($glue, $column, $operator, $values, 'having'); |
| 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Renders the full HAVING clause. |
| 594 | * |
| 595 | * @return string|null The full clause or null if has not a clause |
| 596 | */ |
| 597 | protected function renderHaving() : ?string |
| 598 | { |
| 599 | return $this->renderWhere('having'); |
| 600 | } |
| 601 | } |