Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Assert.php

function Assert::valueToString

Parameters

mixed $value:

Return value

string

60 calls to Assert::valueToString()
Assert::alnum in vendor/webmozart/assert/src/Assert.php
@psalm-pure
Assert::alpha in vendor/webmozart/assert/src/Assert.php
@psalm-pure
Assert::classExists in vendor/webmozart/assert/src/Assert.php
@psalm-assert class-string $value
Assert::contains in vendor/webmozart/assert/src/Assert.php
@psalm-pure
Assert::digits in vendor/webmozart/assert/src/Assert.php
@psalm-pure

... See full list

File

vendor/webmozart/assert/src/Assert.php, line 2000

Class

Assert
Efficient assertions to validate the input/output of your methods.

Namespace

Webmozart\Assert

Code

protected static function valueToString($value) {
    if (null === $value) {
        return 'null';
    }
    if (true === $value) {
        return 'true';
    }
    if (false === $value) {
        return 'false';
    }
    if (\is_array($value)) {
        return 'array';
    }
    if (\is_object($value)) {
        if (\method_exists($value, '__toString')) {
            return \get_class($value) . ': ' . self::valueToString($value->__toString());
        }
        if ($value instanceof DateTime || $value instanceof DateTimeImmutable) {
            return \get_class($value) . ': ' . self::valueToString($value->format('c'));
        }
        return \get_class($value);
    }
    if (\is_resource($value)) {
        return 'resource';
    }
    if (\is_string($value)) {
        return '"' . $value . '"';
    }
    return (string) $value;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal