Lines 100.00% 1 / 1
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ScopeCondition 100.00% 1 / 1 100.00% 1 / 1 1 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace BlueprintAU\Radiant;
6
7use BlueprintAU\Radiant\Database\Query\Enums\WhereBoolean;
8use BlueprintAU\Radiant\Database\Query\Enums\WhereOperator;
9
10/**
11 * One trait-declared query scope condition.
12 *
13 * Collected from `#[ModelScope]`-annotated trait methods; a trait's
14 * conditions group in ONE nested where group marked with the trait, so
15 * an opt-out strips the trait's whole scope atomically. The boolean
16 * joins a condition to the PREVIOUS one within that group (the first
17 * condition's boolean is ignored); between traits the groups always
18 * AND — each trait's scope is a hard filter, never an OR escape.
19 */
20final class ScopeCondition
21{
22    /**
23     * Create a scope condition.
24     *
25     * @param  string  $column  The DB column name (validated at metadata build).
26     * @param  WhereOperator  $operator  The operator (Null/NotNull/eq-style).
27     * @param  mixed  $value  The comparison value; encoded through the column's cast at apply time.
28     * @param  WhereBoolean  $boolean  How this condition joins the previous one in the same trait's group.
29     */
30    final public function __construct(
31        public readonly string $column,
32        public readonly WhereOperator $operator,
33        public readonly mixed $value = null,
34        public readonly WhereBoolean $boolean = WhereBoolean::And,
35    ) {
36    }
37}