protected function cleanBooleanValue($val)
    {
        if ($val !== null) {
            if ($val === 1 || $val === '1' || $val === 0 || $val === '0') {
                $val = (bool)$val;
            } elseif (is_string($val) && trim($val) === '') {
                $val = null;
            }
        }
        return $val;
    }