Generates a suitable variable name to be used for a given value.

@param mixed $value A value.
@return string A variable name without the leading dollar sign ('$').
196542
public function generateVariableName($value)
    {
        $occurence = 0;

        if (is_object($value) === true) {
            $counter = $this->getObjectCount();
            $className = get_class($value);

            if (isset($counter[$className]) === false) {
                $occurence = 0;
                $counter[$className] = $occurence;
            } else {
                $occurence = $counter[$className];
            }

            $counter[$className] += 1;
            $this->setObjectCount($counter);
        } else {
            if (is_null($value) === true) {
                $type = 'null';
            } else {
                $type = gettype($value);
            }

            $counter = $this->getDatatypeCount();
            $occurence = $counter[$type];
            $counter[$type] += 1;

            $this->setDatatypeCount($counter);
        }

        return PhpMarshallingUtils::variableName($value, $occurence);
    }
1123505
public static function format($value)
    {
        $value = Utils::toString($value);
        $bn = Utils::toBn($value);
        $int = (int) $bn->toString();

        return $int;
    }
1013787
protected function addValue($value)
    {
        $name                = 'where' . $this->whereContainer->getBindingCount();
        $this->values[$name] = $value;

        return ':' . $name;
    }
539799
public static final function cast($value): string {
		if (is_string($value)){
			return $value;
		}

		if (is_object($value) && method_exists($value, 'toString')){
			return $value->toString();
		}

		if (is_object($value) && method_exists($value, '__toString')){
			return $value->__toString();
		}

		if ($value instanceof \Generator){
			return self::join('', iterator_to_array($value, false));
		}

		return (string)$value;
	}
31918
public static function camelCase($value)
  {
    $value = ucwords(str_replace(array('-', '_'), ' ', $value));
    $value = str_replace(' ', '', $value);
    $value[0] = strtolower($value[0]);
    return $value;
  }
822059
protected function valueToString($value) : string
    {
        if ($value === null) {
            $def_value = 'null';
        } elseif ($value === false) {
            $def_value = 'false';
        } elseif ($value === true) {
            $def_value = 'true';
        } elseif (is_string($value)) {
            $def_value = '"' . str_replace('"', '\\"', $value) . '"';
        } elseif (is_numeric($value)) {
            $def_value = '' . $value;
        }

        return $def_value;
    }
29701
static private function stringify($value)
        {
            if (is_bool($value)) {
                return $value ? '<TRUE>' : '<FALSE>';
            }

            if (is_scalar($value)) {
                $val = (string) $value;

                if (strlen($val) > 100) {
                    $val = substr($val, 0, 97) . '...';
                }

                return $val;
            }

            if (Arrays::is($value)) {
                return '<ARRAY>';
            }

            if (is_object($value)) {
                return get_class($value);
            }

            if (is_resource($value)) {
                return '<RESOURCE>';
            }

            if ($value === null) {
                return '<NULL>';
            }

            return 'unknown';
        }
585314
private function getValueAsString($value): string
    {
        if (is_bool($value)) {
            return $value ? 'true' : 'false';
        }

        if (is_float($value)) {
            $value = (string) $value;
            if (false === strpos($value, '.')) {
                $value .= '.0';
            }

            return $value;
        }

        if (is_int($value)) {
            return (string) $value;
        }

        throw new \InvalidArgumentException(sprintf('Unsupported data type: %s', gettype($value)));
    }
590300
protected function wrapValue($value)
    {
        if ($this->isReserved($value)) {
            return Str::upper(parent::wrapValue($value));
        }

        return $value !== '*' ? sprintf($this->wrapper, $value) : $value;
    }
28437
public static function localize($value)
    {
        $convert = localeconv();
        $value = str_replace(".", $convert['decimal_point'], (string) $value);
        if (!empty($convert['negative_sign']) and (strpos($value, "-"))) {
            $value = str_replace("-", $convert['negative_sign'], $value);
        }
        return $value;
    }
882344
protected function formatValue($value)
    {
        $formatted_value = '<unknown parameter type>';

        if (is_object($value)) {
            $formatted_value = '<' . get_class($value) . ' object>';
        } elseif ($value === null) {
            $formatted_value = '<null>';
        } elseif (is_string($value)) {
            if (SwatString::validateUtf8($value)) {
                $formatted_value = "'" . $value . "'";
            } else {
                $formatted_value = '"' . SwatString::escapeBinary($value) . '"';
            }
        } elseif (is_int($value) || is_float($value)) {
            $formatted_value = strval($value);
        } elseif (is_bool($value)) {
            $formatted_value = $value ? 'true' : 'false';
        } elseif (is_resource($value)) {
            $formatted_value = '<resource>';
        } elseif (is_array($value)) {
            // check whether or not array is associative
            $keys = array_keys($value);
            $associative = false;
            $count = 0;
            foreach ($keys as $key) {
                if ($key !== $count) {
                    $associative = true;
                    break;
                }
                $count++;
            }

            $formatted_value = 'array(';

            $count = 0;
            foreach ($value as $key => $the_value) {
                if ($count > 0) {
                    $formatted_value .= ', ';
                }

                if ($associative) {
                    $formatted_value .= $this->formatValue($key);
                    $formatted_value .= ' => ';
                }
                $formatted_value .= $this->formatValue($the_value);
                $count++;
            }
            $formatted_value .= ')';
        }

        return $formatted_value;
    }
142378
public function resourceName($value = null)
    {
        if ($value !== null) {
            return $this->setConfig('name', $value);
        }

        if (empty($this->_config['name'])) {
            $this->setConfig('name', $this->_deriveResourceName());
        }

        return $this->getConfig('name');
    }
804051
public static function getKey(string $value): string
    {
        self::assertIsValidValue($value);

        return (string) array_search($value, static::toArray(), true);
    }
180615
public static function toPHPVariableString($value)
    {
		switch (gettype($value)) {
        	case "string" :
        	    $returnValue = '\''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $value)).'\'';
        		break;
        	case "boolean" :
        		$returnValue = $value ? 'true' : 'false';
        		break;
        	case "integer" :
        	case "double" :
        		$returnValue = $value;
        		break;
        	case "array" :
				$string = "";
				foreach ($value as $key => $val) {
					$string .= self::toPHPVariableString($key)." => ".self::toPHPVariableString($val).",";
				}
				$returnValue = "array(".substr($string, 0, -1).")";
				break;
        	case "NULL" :
        		$returnValue = 'null';
				break;
        	case "object" :
        	    if ($value instanceof PhpSerializable) {
        	       $returnValue = $value->__toPhpCode();
        	    } else {
        	       $returnValue =  'unserialize('.self::toPHPVariableString(serialize($value)).')';
        	    }
        		break;
        	default:
    			// resource and unexpected types
        		throw new common_exception_Error("Could not convert variable of type ".gettype($value)." to PHP variable string");
        }

        return (string) $returnValue;
    }
409849
public function format($value, string $format = null)
    {
        $formatted = number_format(
            $value,
            $this->decimals,
            $format === 'nomask' ? '' : $this->decimal,
            $format === 'nomask' ? '' : $this->thousand
        );

        switch ($format) {
            case 'name':
                $name = $this->name_plural;
                if (!$name || (float) $value === 1.0) {
                    $name = $this->name;
                }
                return $formatted . ' ' . $name;
                break;

            case 'raw':
            case 'nomask':
                return $formatted;
                break;

            case 'symbol':
            default:
                return $this->symbol . ' ' . $formatted;
                break;
        }
    }
598252
private function initializeVariables($value)
    {
        preg_match_all('/\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', $value, $matches);

        foreach (array_unique($matches[0]) as $variable) {
            $value = "<?php $variable = isset($variable) ? $variable : null; ?>\n".$value;
        }

        return $value;
    }
1017254
public function bind($value)
    {
        //Argument 1 must be an array, string or number
        Argument::i()->test(1, 'array', 'string', 'numeric', 'null');
        
        if (is_array($value)) {
            foreach ($value as $i => $item) {
                $value[$i] = $this->bind($item);
            }
            
            return '('.implode(",", $value).')';
        } else if (is_int($value) || ctype_digit($value)) {
            return $value;
        }
        
        $name = ':bind'.count($this->binds).'bind';
        $this->binds[$name] = $value;
        return $name;
    }