18 private string $fieldName,
19 private string $tableName
25 if ( $value ===
null || is_bool( $value ) ) {
28 throw new \InvalidArgumentException(
'Invalid value for tri-state boolean' );
32 public function evaluate( stdClass $row, $value ): bool {
33 $rowValue = $row->{ $this->fieldName };
34 if ( $rowValue !==
null ) {
35 $rowValue = (bool)$rowValue;
37 return $rowValue === $value;
43 $query->
fields( $this->fieldName );
48 $set = $this->getEnumValues( [
false,
true,
null ] );
49 if ( $set ===
null ) {
51 } elseif ( $set === [] ) {
54 $null = in_array(
null, $set,
true );
55 $false = in_array(
false, $set,
true );
56 $true = in_array(
true, $set,
true );
63 if ( !$true || !$false || $null ) {
65 foreach ( $set as $value ) {
66 $orConds[] = $dbr->
expr( $this->fieldName,
'=', $value );
68 if ( count( $orConds ) > 1 ) {
71 $query->
where( $orConds[0] );