Format anything into boolean.
@param mixed input
@return boolean
546597
public static function toBoolean($input = false) {

        if ($input) {

            $boolean = (bool) $input;
            if (Validate::isBoolean($boolean)) {

                return $boolean;
            }
        }

        return false;
    }
1292171
public function prepare($input)
    {
        $form = $this->buildNestedForm($this->column, $this->builder);

        return $form->setOriginal($this->original, $this->getKeyName())->prepare($input);
    }
952170
protected function convertNegativeTo($input)
    {
        $res = $this->convertPositiveTo(substr($input, 1));

        $res = strtr($res, static::POSITIVE_CHARS, static::NEGATIVE_CHARS);

        if (strlen($res) < 5) {
            $res = '/' . $res;
        } elseif ($res[0] !== '!') {
            $res = '*' . $res;
        }

        return $res;
    }
741836
private function withParam( string$input )
	{
		return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
			$param= $this->param;

			if( isset($matches[1]) ){
				array_map(...[
					function($replacer)use(&$param){
						list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
						$param= preg_replace(...[
							"/$pattern/",
							preg_replace('/^\\\\_$/','',$replacement),
							$param,
						]);
					},
					preg_split(
						'/(?<!\\\\)\\/\\//'
						,
						trim($matches[1],'/')
					),
				]);
			}
			return $param;
		},$input));
	}
315527
public function normalize($input)
    {
        foreach ($this->normalizers as $normalizer) {
            if ($normalizer->accept($input)) {
                $input = $normalizer->normalize($input);
            }
        }

        return $input;
    }
601525
protected function validate(string $input): bool
    {
        return preg_match($this->realNumber ? self::REAL_NUMBER_REGEXP : self::INTEGER_REGEXP, $input) === 1;
    }
1158627
public static function isUrl($input = false) {

        if ($input && !filter_var($input, FILTER_VALIDATE_URL) === false) {

            return true;
        }

        return false;
    }
818884
public static function clean($input)
    {
        // handle input of type array
        if (is_array($input)) {
            foreach ($input as $idx => $val) {
                $input[$idx] = self::clean($val);
            }
            return $input;
        }

        if (!is_string($input) || $input == '') {
            return $input;
        }

        // iconv/mbstring are much faster (especially with long strings)
        if (function_exists('mb_convert_encoding')) {
            $msch = mb_substitute_character();
            mb_substitute_character('none');
            $res = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
            mb_substitute_character($msch);

            if ($res !== false) {
                return $res;
            }
        }

        if (function_exists('iconv')) {
            if (($res = @iconv('UTF-8', 'UTF-8//IGNORE', $input)) !== false) {
                return $res;
            }
        }

        $seq    = '';
        $out    = '';
        $regexp = '/^('.
//          '[\x00-\x7F]'.                                  // UTF8-1
            '|[\xC2-\xDF][\x80-\xBF]'.                      // UTF8-2
            '|\xE0[\xA0-\xBF][\x80-\xBF]'.                  // UTF8-3
            '|[\xE1-\xEC][\x80-\xBF][\x80-\xBF]'.           // UTF8-3
            '|\xED[\x80-\x9F][\x80-\xBF]'.                  // UTF8-3
            '|[\xEE-\xEF][\x80-\xBF][\x80-\xBF]'.           // UTF8-3
            '|\xF0[\x90-\xBF][\x80-\xBF][\x80-\xBF]'.       // UTF8-4
            '|[\xF1-\xF3][\x80-\xBF][\x80-\xBF][\x80-\xBF]'.// UTF8-4
            '|\xF4[\x80-\x8F][\x80-\xBF][\x80-\xBF]'.       // UTF8-4
            ')$/';

        for ($i = 0, $len = strlen($input); $i < $len; $i++) {
            $chr = $input[$i];
            $ord = ord($chr);

            // 1-byte character
            if ($ord <= 0x7F) {
                if ($seq !== '') {
                    $out .= preg_match($regexp, $seq) ? $seq : '';
                    $seq = '';
                }

                $out .= $chr;
            }
            // first byte of multibyte sequence
            else if ($ord >= 0xC0) {
                if ($seq !== '') {
                    $out .= preg_match($regexp, $seq) ? $seq : '';
                    $seq = '';
                }

                $seq = $chr;
            }
            // next byte of multibyte sequence
            else if ($seq !== '') {
                $seq .= $chr;
            }
        }

        if ($seq !== '') {
            $out .= preg_match($regexp, $seq) ? $seq : '';
        }

        return $out;
    }
942584
protected function validate_boolean($field, $input, $param = null)
    {
        if (!isset($input[$field]) || empty($input[$field]) && $input[$field] !== 0) {
            return;
        }

        $booleans = array('1','true',true,1,'0','false',false,0,'yes','no','on','off');
        if (in_array($input[$field], $booleans, true )) {
            return;
        }

        return array(
            'field' => $field,
            'value' => $input[$field],
            'rule' => __FUNCTION__,
            'param' => $param,
        );
    }
795061
private static function _prepareQuestionString($input)
    {
        $regex = '';
        if (is_array($input) === true) {
            $regex = '^';
            $start = true;
            foreach ($input as $row) {
                if ($start === false) {
                    $regex .= '|';
                }

                $start  = false;
                $regex .= '(';
                $one    = null;
                if (strlen($row) > 2) {
                    $one = true;
                }

                foreach (str_split($row, 1) as $char) {
                    $regex .= '[' . $char;
                    $regex .= strtoupper($char) . ']';
                    if ($one === true) {
                        $one    = false;
                        $regex .= '(';
                    }
                }

                if ($one === false) {
                    $regex .= ')';
                }

                $regex .= '?)';
            }
        }

        return $regex;
    }
1295009
public function convert($input)
    {
        if (!$input) {
            return;
        }

        if (!($input instanceof \DateTime)) {
            throw new UnexpectedValueException('Input must be DateTime object.');
        }

        return $input->format($this->outputFormat);
    }
157197
public function hash($input) {
		$hash = crypt($input, $this->getSalt());

		if(strlen($hash) > 13)
			return $hash;

		return false;
	}
799138
public function match($input)
    {
        if ($this->token instanceof Token) {
            if ($this->token->matches($input)) {
                return true;
            }
            return false;
        }
        
        if ($this->token === $input) {
            return true;
        }
        return false;
    }
1068342
public static function byte2intSplit($input)
    {
        $l = strlen($input);
        if ($l <= 0) {
            // right...
            return 0;
        } elseif (($l % 4) != 0) {
            // invalid input
            return false;
        }
        $result = array();
        for ($i = 0; $i < $l; $i += 4) {
            $int_build  = (ord($input[$i]) << 24);
            $int_build += (ord($input[$i+1]) << 16);
            $int_build += (ord($input[$i+2]) << 8);
            $int_build += (ord($input[$i+3]));
            $result[] = $int_build;
        }

        return $result;
    }
1141650
public function sanitize($input)
    {
        foreach ($this->rawRules as $rule) {
            if ($rule instanceof Attributes) {
                $config = [
                    'remainder' => $this->remainder,
                    'recursive' => $this->recursive
                ];
                Instance::configure($rule, $config);
                return $rule->sanitize($input);
            }
            $input = $rule->sanitize($input);

            if ($rule->recursive && (is_array($input) || is_object($input))) {
                $config['attributes'] = $this;
                return (new Attributes($config))->sanitize($input);
            }
        }

        return $input;
    }
71364
public static function date($input) {
        $input = Time::toUnix($input);

        if (!$input) {
            return false;
        }

        list($m, $d, $y) = explode('/', date('m/d/Y', $input));

        return checkdate($m, $d, $y);
    }
1310567
public static function date($input = null, $format = 'MM/DD/YYYY')
	{
		if (empty($input)) {
			return true;
		}

		switch($format) {
			case 'YYYY/MM/DD':
			case 'YYYY-MM-DD':
			list($y, $m, $d) = preg_split('/[-\.\/ ]/', $input);
			break;

			case 'YYYY/DD/MM':
			case 'YYYY-DD-MM':
			list($y, $d, $m) = preg_split('/[-\.\/ ]/', $input);
			break;

			case 'DD-MM-YYYY':
			case 'DD/MM/YYYY':
			list($d, $m, $y) = preg_split('/[-\.\/ ]/', $input);
			break;

			case 'MM-DD-YYYY':
			case 'MM/DD/YYYY':
			list($m, $d, $y) = preg_split('/[-\.\/ ]/', $input);
			break;

			case 'YYYYMMDD':
			$y = substr($input, 0, 4);
			$m = substr($input, 4, 2);
			$d = substr($input, 6, 2);
			break;

			case 'YYYYDDMM':
			$y = substr($input, 0, 4);
			$d = substr($input, 4, 2);
			$m = substr($input, 6, 2);
			break;

			default:
			throw new \InvalidArgumentException("Invalid Date Format");
		}
		return checkdate($m, $d, $y);
	}