拓展case
@param string|boolean $condition 条件
@param string $value 可以更改输出的值，不必先用 $this->swi
@return null|string
347903
public function cas($condition, $value = null) {
		if (!is_null($value)) {
			$this->_switchValue = $value;
		}
		if ((is_null($this->_switchCondition) && true === $condition) ||
			(!is_null($this->_switchCondition) && $this->_switchCondition == $condition)) {
			return $this->_switchValue;
		}
		return null;
	}
1060855
public function getBooleanValue($value)
    {
        if ($value === null) {
            return;
        }

        if ($this->listData) {
            reset($this->listData);
            list(, $yes_value) = @each($this->listData);
            list(, $no_value) = @each($this->listData);
            if ($no_value === null) {
                $no_value = '';
            }
            /* not to convert N to Y */
            if ($yes_value == $value) {
                return $yes_value;
            }
            if ($no_value == $value) {
                return $no_value;
            }
        } else {
            $yes_value = 1;
            $no_value = 0;
        }

        return $value ? $yes_value : $no_value;
    }
1012106
public static function resolve($value)
    {
        switch (strtolower($value)) {
            case self::NEWEST:
                return self::NEWEST;
            case self::AUTHORIZED:
                return self::AUTHORIZED;
            case self::NOT_AUTHORIZED:
                return self::NOT_AUTHORIZED;
            case self::PAID:
                return self::PAID;
            case 'canceled':
            case self::CANCELLED:
                return self::CANCELLED;
            case self::WAITING:
                return self::WAITING;
        }

        return null;
    }
1338494
protected function getBoolFromStringBool($value)
    {
        if (!($value == 'true' || $value == 'false')) {
            $this->throwException(sprintf('Expected "true" or "false" but got %s', $value));
        }

        return $value === 'true' ? true : false;
    }
1151782
public static function toBool($value)
    {
        if ($value instanceof Countable) {
            return (bool)count($value);
        }

        if (!static::isStringLike($value)) {
            return (bool)$value;
        }

        $string = "$value";

        if (trim($string) == '') {
            return false;
        }

        if (in_array(strtolower($value), ['0', 'false'], true)) {
            return false;
        }

        return (bool)$string;

    }
726675
public function ruleValue($value = null)
    {
        if (\func_num_args() > 0) {
            if (null !== $value && $this->validateValue($value)) {
                $this->value = $value;
                $this->updateBound();

                return true;
            }
            return false;
        }
        return $this->value;
    }
64537
protected function getBooleanValue($value)
    {
        if (is_string($value)) {
            return 'true' === $value ? true : false;
        } elseif (is_bool($value)) {
            return $value;
        } elseif (is_numeric($value)) {
            return 1 === $value ? true : false;
        }
    }
744196
public function where($condition, $value = null, $type = null) {
		$this->_criteria->andWhere($condition);
		
		return $this;
	}
170607
final public function addPropertyIf(Bool $condition=null, String $property, $value=null)
	{
		if ($condition == true) {
			$this->softProperties[$property] = $value;
		}
	}
301508
public function where($condition, $value = null): object
    {
        if (!is_array($condition)) {
            $condition = [$condition => $value];
        }
        $this->container[$this->id]['s']['where'] = array_merge($this->container[$this->id]['s']['where'], $condition);
        return $this;
    }
27905
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!is_bool($value)) {
            throw new TransformationFailedException('Expected a boolean.');
        }

        return $value ? $this->trueValue : $this->falseValue;
    }
550953
public function isFiltered($condition, $value, $type)
    {
        $isFiltered = true;
        switch ($condition[1]) {
        case '=':
        case '==':
        case 'equal':
            if ($type === 'string' && is_string($value) && is_string($condition[2])) {
                $isFiltered = strcmp($value, $condition[2]) == 0;
            } else {
                $isFiltered = $value == $condition[2];
            }

            break;
        case '!=':
        case 'notEqual':
            if ($type === 'string' && is_string($value) && is_string($condition[2])) {
                $isFiltered = strcmp($value, $condition[2]) != 0;
            } else {
                $isFiltered = $value != $condition[2];
            }

            break;
        case '>':
        case 'gt':
            if ($type === 'string') {
                $isFiltered = strcmp($value, $condition[2]) > 0;
            } else {
                $isFiltered = $value > $condition[2];
            }

            break;
        case '>=':
            if ($type === 'string') {
                $isFiltered = strcmp($value, $condition[2]) >= 0;
            } else {
                $isFiltered = $value >= $condition[2];
            }

            break;
        case '<':
        case 'lt':
            if ($type === 'string') {
                $isFiltered = strcmp($value, $condition[2]) < 0;
            } else {
                $isFiltered = $value < $condition[2];
            }

            break;
        case '<=':
            if ($type === 'string') {
                $isFiltered = strcmp($value, $condition[2]) <= 0;
            } else {
                $isFiltered = $value <= $condition[2];
            }

            break;
        case 'contain':
        case 'contains':
            $isFiltered = strpos(strtolower($value), strtolower($condition[2])) !== false;
            break;
        case 'notContain':
        case 'notContains':
            $isFiltered = strpos(strtolower($value), strtolower($condition[2])) === false;
            break;
        case 'startWith':
        case 'startsWith':
            $isFiltered = strpos(strtolower($value), strtolower($condition[2])) === 0;
            break;
        case 'notStartWith':
        case 'notStartsWith':
            $isFiltered = strpos(strtolower($value), strtolower($condition[2])) !== 0;
            break;
        case 'endWith':
        case 'endsWith':
            $isFiltered = strpos(strrev(strtolower($value)), strrev(strtolower($condition[2]))) === 0;
            break;
        case 'notEndWith':
        case 'notEndsWith':
            $isFiltered = strpos(strrev(strtolower($value)), strrev(strtolower($condition[2]))) !== 0;
            break;
        case 'between':
            $isFiltered = $value > $condition[2] && $value < $condition[3];
            break;
        case 'notBetween':
            $isFiltered = !($value > $condition[2] && $value < $condition[3]);
            break;
        case "in":
            if (!is_array($condition[2])) {
                $condition[2] = array($condition[2]);
            }

            $isFiltered = in_array($value, $condition[2]);
            break;
        case "notIn":
            if (!is_array($condition[2])) {
                $condition[2] = array($condition[2]);
            }

            $isFiltered = !in_array($value, $condition[2]);
            break;
        default:
            break;
        }
        return $isFiltered;
    }
446973
protected static function matchCase($value, $comparison)
    {
        $functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords'];

        foreach ($functions as $function) {
            if (call_user_func($function, $comparison) === $comparison) {
                return call_user_func($function, $value);
            }
        }

        return $value;
    }
230881
public function checkCondition(Value $value)
    {
        return (parent::checkCondition($value) || $value->getValue() == $this->getValue()->getValue());
    }
4258
public function convertQueryCondition($value)
    {
        // First fetch the type
        if (null === $value) {
            return 0;
        }

        if (!is_array($value)) {
            $value = [$value];
        }

        $hasOperator = false;

        // FIXME Sorry for this
        if (!Misc::isIndexed($value)) {
            // We have an operator.
            $operator = array_keys($value)[0];
            $values = $value[$operator][0];
            $hasOperator = true;
        } else {
            $values = $value;
        }

        foreach ($values as $key => $type) {
            if (null === $type) {
                $values[$key] = 0;
            } else if ($typeId = $this->getTypeId($type, false)) {
                $values[$key] = $typeId;
            } else {
                unset($values[$key]);
            }
        }

        if (empty($values)) {
            // It should not have been empty, this is an impossible
            // condition
            $values = [-1];
        }

        if ($hasOperator) {
            return [$operator => $values];
        } else {
            return $values;
        }
    }
30759
private static function bool2str($value){
        //convert boolean to text value.
        $value = $value === true ? 'true' : $value;
        $value = $value === false ? 'false' : $value;
        return $value;
    }
744742
protected function _prepareQuery($value, $condition = '=')
    {
        //tworzenie binda
        $bindKey = PdoBindHelper::generateBindKey();
        //wartość nie null i nie tabelaryczna
        if (!is_array($value) && null !== $value) {
            $this->_query->getQueryCompile()->bind[$bindKey] = $value;
        }
        //inicjalizacja zapytania
        $this->_initQuery();
        //przygotowanie wartości null
        if (null === $value) {
            $this->_query->getQueryCompile()->where .= DbConnector::getAdapter()->prepareNullCheck($this->_fieldName, ($condition == '='));
            return $this->_query;
        }
        //przygotowanie pustych tabel (kompatybilne tylko z == i <>)
        if (is_array($value) && empty($value)) {
            //jeśli tabela jest pusta i negacja to 1 jeśli równość to 0
            $this->_query->getQueryCompile()->where .= $condition == '<>' ? 1 : 0;
            return $this->_query;
        }
        //przygotowanie typów tabelarycznych
        if (is_array($value)) {
            $fields = '';
            //bindowanie parametrów
            foreach ($value as $arg) {
                $bk = PdoBindHelper::generateBindKey();
                $this->_query->getQueryCompile()->bind[$bk] = $arg;
                $fields .= ':' . $bk . ', ';
            }
            //dodawanie IN do where
            $this->_query->getQueryCompile()->where .= $this->_fieldName . ' ' . ($condition == '<>' ? 'NOT IN' : 'IN') . '(' . trim($fields, ', ') . ')';
            return $this->_query;
        }
        //like powinien działać jak ilike
        if ('LIKE' == $condition) {
            $this->_query->getQueryCompile()->where .= DbConnector::getAdapter()->prepareLike($this->_fieldName) . ' :' . $bindKey;
            return $this->_query;
        }
        //zwykłe porównanie
        $this->_query->getQueryCompile()->where .= $this->_fieldName . ' ' . $condition . ' :' . $bindKey;
        return $this->_query;
    }