Uniques and transforms a string value to binary format and adds it to the object table
@param string $val The string value
@return integer The position in the object table
341310
public function stringToBinary($val)
    {
        $saved_object_count = -1;

        if (!isset($this->uniqueTable[$val])) {
            $saved_object_count = $this->writtenObjectCount++;
            $this->uniqueTable[$val] = $saved_object_count;
            $utf16 = false;

            for ($i=0; $i<strlen($val); ++$i) {
                if (ord($val{$i}) >= 128) {
                    $utf16 = true;
                    break;
                }
            }

            if ($utf16) {
                $bdata = self::typeBytes("6", mb_strlen($val, 'UTF-8')); // 6 is 0110, unicode string (utf16be)
                $val = self::convertCharset($val, 'UTF-8', 'UTF-16BE');
                $this->objectTable[$saved_object_count] = $bdata.$val;
            } else {
                $bdata = self::typeBytes("5", strlen($val)); // 5 is 0101 which is an ASCII string (seems to be ASCII encoded)
                $this->objectTable[$saved_object_count] = $bdata.$val;
            }
        } else {
            $saved_object_count = $this->uniqueTable[$val];
        }

        return $saved_object_count;
    }
696553
protected function Eq( $val )
	{
		if  (! $val->getIsNumeric() ) return false;
		return  $this->ToInt( null ) == $val->ToInt( null );
	}
740041
public function storageVal($val)
    {
        if ($val === null || $val === '') {
            // Do not encode NULL values
            return null;
        }

        if ($val instanceof Translation) {
            $val = (string)$val;
        }

        if (!is_scalar($val)) {
            return json_encode($val, JSON_UNESCAPED_UNICODE);
        }

        return $val;
    }
5944
public static function fromCode($val)
    {
        $val = strtoupper($val);
        if (array_key_exists($val, self::$_languages)) {
            return self::$_languages[$val];
        }
        return null;
    }
780870
protected function Div( $val )
	{
		return new DecimalProxy( Convert::ToDouble( $this->_value) /  Convert::Toouble( $val->getValue() ) );
	}
786648
public static function getCode($val)
    {
        if (self::$_languageFlip === array()) {
            self::$_languageFlip = array_flip(self::$_languages);
        }
        if (array_key_exists($val, self::$_languageFlip)) {
            return strtolower(self::$_languageFlip[$val]);
        }
        return null;
    }
269052
public static function convertToInt($val, array $valueSet)
    {
        if ($val === null) {

            return 0;
        }
        if (!is_array($val)) {
            $val = [$val];
        }
        $bitValueArr = array_pad([], count($valueSet), '0');
        foreach ($val as $value) {
            if (!in_array($value, $valueSet)) {
                throw new SetColumnConverterException(sprintf('Value "%s" is not among the valueSet', $value), $value);
            }
            $bitValueArr[array_search($value, $valueSet)] = '1';
        }
        
        return base_convert(implode(array_reverse($bitValueArr)), 2, 10);
    }
55726
public function save($val)
    {
        $password = $val;

        // Assuming the password_needs_rehash is set to true is the hash given isn't a hash
        if (password_needs_rehash($password, PASSWORD_DEFAULT)) {
            $val = password_hash($password, PASSWORD_DEFAULT);
        }

        return $val;
    }
79434
private function encodeValue($val, $base)
    {
        $this->preOpMethodParamsCheck(array($val, $base));

        $digits = $this->baseCheck($base);

        try {

            $new = '';

            while ($this->math->comp($val, '0') > 0) {
                $qq  = $this->math->div($val, $base);
                $rem = $this->math->mod($val, $base);
                $val = $qq;
                $new = $new . $digits[$rem];
            }

            return $new;

        } catch (\Exception $e) {
            throw $e;
        }
    }
1075349
public function Mul( $val )
	{
		$value = $val instanceof DecimalValue ? $val : Convert::ToDecimal( $val );
		return new DecimalValue( bcmul( $this->_value, $value->getValue(), $this->getScale() + $this->scale( $value ) ) );
	}
253229
protected function returnBytes($val)
    {
        $val = trim($val);
        $last = strtolower($val[strlen($val)-1]);
        // Do not add breaks in the switch below
        switch ($last) {
            // The 'G' modifier is available since PHP 5.1.0
            case 'g':
                $val = (int)$val*1024;
                // no break
            case 'm':
                $val = (int)$val*1024;
                // no break
            case 'k':
                $val = (int)$val*1024;
        }

        return $val;
    }
582778
protected function Mul( $val )
	{
		if ( ! $val instanceof ByteProxy ) throw new \InvalidArgumentException();
		return new IntProxy( $this->_value * $val->_value );
	}
1345209
protected function Add( $val )
	{
		if  (! $val->getIsNumeric() ) return $this;
		$value2 = $val->ToInt( null );
		$integer = ValueProxy::Unwrap( $this );
	    return new IntegerProxy( $integer->getValue() + $value2 );
	}
349502
protected function encode($val) {
		switch (true) {
			case is_array($val):
				return self::T_ARRAY . json_encode($val);
			case is_int($val):
				return self::T_INT . $val;
			case is_bool($val):
				return self::T_BOOLEAN . $val;
			case is_float($val):
				return self::T_DOUBLE . $val;
			case is_object($val):
				return self::T_OBJECT . serialize($val);
			default:
				return self::T_STRING . $val;
		}
	}
663113
protected function Div( $val )
	{
		if  (! $val->getIsNumeric() ) return $this;
		$value1 = $this->ToDecimal( null );
		$value2 = $val->ToDecimal( null );
		return $value1->Div( $value2 );
	}
518225
protected function duplicateBorder(&$val)
    {
        // 1 value => L => RTB
        if (count($val) == 1) {
            $val[1] = $val[0];
            $val[2] = $val[0];
            $val[3] = $val[0];
        // 2 values => L => R & T => B
        } elseif (count($val) == 2) {
            $val[2] = $val[0];
            $val[3] = $val[1];
        // 3 values => T => B
        } elseif (count($val) == 3) {
            $val[3] = $val[1];
        }
    }
378306
public function Add( $val )
	{
		$value = $val instanceof DecimalValue ? $val : Convert::ToDecimal( $val );
		return new DecimalValue( bcadd( $this->_value, $value->getValue(), max( $this->getScale(), $this->scale( $value ) ) ) );
	}