Determine if the value is translatable.

@param  mixed $val The value to be checked.
@return boolean
969459
protected function isValidTranslation($val)
    {
        if (empty($val) && !is_numeric($val)) {
            return false;
        }

        if (is_string($val)) {
            return !empty(trim($val));
        }

        if ($val instanceof Translation) {
            return true;
        }

        if (is_array($val)) {
            return !!array_filter(
                $val,
                function ($v, $k) {
                    if (is_string($k) && strlen($k) > 0) {
                        if (is_string($v) && strlen($v) > 0) {
                            return true;
                        }
                    }

                    return false;
                },
                ARRAY_FILTER_USE_BOTH
            );
        }
        return false;
    }
671733
public static function isISODate($val)
    {
        if(!is_string($val)) {
            return false;
        }

        // Use DateTime support to check for valid dates.
        try
        {
            $date = new DateTime($val);
        }
        catch(Exception $e)
        {
            return false;
        }

        return true;
    }
308207
public function getFilterValue($val)
    {
        $formatter = $this->getFormatter();

        if (strlen($this->getPrefix()) > 0 && strpos($val, $this->getPrefix()) === 0) {
            $val = substr($val, strlen($this->getPrefix()));
        }
        if (strlen($this->getSuffix()) > 0 && strpos($val, $this->getSuffix()) > 0) {
            $val = substr($val, 0, -strlen($this->getSuffix()));
        }

        try {
            $formattedValue = $formatter->parse($val);
        } catch (\Exception $e) {
            return $val;
        }

        if (false === $formattedValue) {
            return $val;
        }

        return $formattedValue;
    }
742888
public function get($val)
    {
        // If we already have the code, just return that
        if (is_numeric($val)) {
            return $val;
        }

        if (array_key_exists($val, $this->formats)) {
            return $this->formats[$val];
        }

        return null;
    }
1338787
public static function isEmpty($val): bool
    {
        if (\is_string($val)) {
            $val = \trim($val);

        } elseif (\is_object($val)) {
            $val = \get_object_vars($val);
        }

        return $val === '' || $val === null || $val === [];
    }
1066991
public static function json($val, $strict = true): bool
    {
        if (!$val || (!\is_string($val) && !\method_exists($val, '__toString'))) {
            return false;
        }

        $val = (string)$val;

        // must start with: { OR [
        if ($strict && '[' !== $val[0] && '{' !== $val[0]) {
            return false;
        }

        \json_decode($val);

        return \json_last_error() === \JSON_ERROR_NONE;
    }
692437
public function displayVal($val, array $options = [])
    {
        if ($val === null || $val === '') {
            return '';
        }

        /** Parse multilingual values */
        if ($this->l10n()) {
            $propertyValue = $this->l10nVal($val, $options);
            if ($propertyValue === null) {
                return '';
            }
        } elseif ($val instanceof Translation) {
            $propertyValue = strval($val);
        } else {
            $propertyValue = $val;
        }

        $separator = $this->multipleSeparator();

        /** Parse multiple values / ensure they are of array type. */
        if ($this->multiple()) {
            if (!is_array($propertyValue)) {
                $propertyValue = explode($separator, $propertyValue);
            }
        }

        if ($separator === ',') {
            $separator = ', ';
        }

        if (is_array($propertyValue)) {
            foreach ($propertyValue as &$value) {
                $value = strval($this->valLabel($value, $options));
            }
            $propertyValue = implode($separator, $propertyValue);
        } else {
            $propertyValue = strval($this->valLabel($propertyValue, $options));
        }

        return $propertyValue;
    }
1111375
private function _extractComparisonTypeAndValue($val)
    {
        $validComparisons = [
            self::COMPARISON_TYPE_GREATERTHAN_EQUAL,
            self::COMPARISON_TYPE_LESSTHAN_EQUAL,
            self::COMPARISON_TYPE_NOT_EQUAL,
            self::COMPARISON_TYPE_GREATERTHAN,
            self::COMPARISON_TYPE_LESSTHAN,
            self::METHOD_LOGIC_TYPE_EQUAL
        ];
        $comparison = substr($val, 0, 2);
        switch ($comparison) {
            case self::COMPARISON_TYPE_GREATERTHAN_EQUAL:
                $type = self::METHOD_LOGIC_TYPE_GREATERTHAN_EQUAL;
                break;
            case self::COMPARISON_TYPE_LESSTHAN_EQUAL:
                $type = self::METHOD_LOGIC_TYPE_LESSTHAN_EQUAL;
                break;
            case self::COMPARISON_TYPE_NOT_EQUAL:
                $type = self::METHOD_LOGIC_TYPE_NOT_EQUAL;
                break;
        }
        if (empty($type)) {
            $comparison = substr($val, 0, 1);
            switch ($comparison) {
                case self::COMPARISON_TYPE_GREATERTHAN:
                    $type = self::METHOD_LOGIC_TYPE_GREATERTHAN;
                    break;
                case self::COMPARISON_TYPE_LESSTHAN:
                    $type = self::METHOD_LOGIC_TYPE_LESSTHAN;
                    break;
                default:
                    $type = self::METHOD_LOGIC_TYPE_EQUAL;
            }
        }

        return (object) [
            'type' => $type,
            'value' => (is_string($val) && in_array($comparison, $validComparisons))
                ? str_replace($comparison, '', $val)
                : $val
        ];
    }
773034
protected function validate_scale($val) {
        global $COURSE;
        $scales = get_scales_menu($COURSE->id);
        return (!empty($val) && isset($scales[(int)$val])) ? true : false;
    }
1229602
private static function toBytes($val) {
        $val = trim($val);
        $last = strtolower($val[strlen($val) - 1]);
        switch ($last) {
            // The 'G' modifier is available since PHP 5.1.0
            case 'g':
                $val *= 1024;
            case 'm':
                $val *= 1024;
            case 'k':
                $val *= 1024;
        }
        return $val;
    }
784144
public static function isMap($val): bool
    {
        if (!\is_array($val)) {
            return false;
        }

        /** @var array $val */
        $keys = \array_keys($val);

        return \array_keys($keys) !== $keys;
    }
1071884
public static function isPrime($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        if (
            ($val<=1) ||
            ($val>2 && ($val%2)===0)
        ) {
            return false;
        }
        for ($i=2;$i<$val;$i++) {
            if (($val%$i)===0) {
                return false;
            }
        }
        return true;
    }
197087
public static function isList($val): bool
    {
        if (!\is_array($val) || !isset($val[0])) {
            return false;
        }

        /** @var array $val */
        $keys = \array_keys($val);

        return \array_keys($keys) === $keys;
    }
31505
public function getUserValue($val)
    {
        $formatter = $this->getFormatter();

        $formattedValue = $formatter->format($val, $this->getFormatType());

        return (string) $this->getPrefix().$formattedValue.$this->getSuffix();
    }
394976
function c($val) {
		$locale=setlocale(LC_NUMERIC,0);
		setlocale(LC_NUMERIC,'C');
		$out=(string)(float)$val;
		$locale=setlocale(LC_NUMERIC,$locale);
		return $out;
	}
273800
public static function isLuhn($val = null)
    {
        if (is_null($val)) {
            return null;
        }
        $_num = substr($val, 0, strlen($val)-1);
        return (bool) (intval($val) == intval($_num.self::getLuhnKey($_num)));
    }
1028535
public function match(View $view)
    {
        if (!$view instanceof TagValueView) {
            return false;
        }

        $keyword = $this->translationHelper->getTranslatedByMethod(
            $view->getTag(),
            'getKeyword'
        );

        return isset($this->values[$keyword]);
    }