Webmozart\Expression\Util\StringUtil::formatValue PHP Method

formatValue() public static method

Formats a value as string.
public static formatValue ( mixed $value ) : string
$value mixed The value.
return string The value as string.
    public static function formatValue($value)
    {
        if (null === $value) {
            return 'null';
        }
        if (true === $value) {
            return 'true';
        }
        if (false === $value) {
            return 'false';
        }
        if (is_string($value)) {
            return '"' . $value . '"';
        }
        if (is_object($value)) {
            return 'object';
        }
        if (is_array($value)) {
            return 'array';
        }
        return (string) $value;
    }

Usage Example

示例#1
0
 /**
  * {@inheritdoc}
  */
 public function toString()
 {
     return 'contains(' . StringUtil::formatValue($this->comparedValue) . ')';
 }
All Usage Examples Of Webmozart\Expression\Util\StringUtil::formatValue