You are here

protected function AssertHelperTrait::castSafeStrings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/AssertHelperTrait.php \Drupal\simpletest\AssertHelperTrait::castSafeStrings()

Casts MarkupInterface objects into strings.

Parameters

string|array $value: The value to act on.

Return value

mixed The input value, with MarkupInterface objects casted to string.

32 calls to AssertHelperTrait::castSafeStrings()
AssertHelperTestClass::testMethod in core/modules/simpletest/tests/src/Unit/AssertHelperTraitTest.php
BlockInterfaceTest::testBlockInterface in core/modules/block/src/Tests/BlockInterfaceTest.php
Test configuration and subsequent form() and build() method calls.
BookUninstallValidatorTest::testValidateEntityQueryWithoutResults in core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
@covers ::validate
BookUninstallValidatorTest::testValidateEntityQueryWithResults in core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
@covers ::validate
BookUninstallValidatorTest::testValidateNotBook in core/modules/book/tests/src/Unit/BookUninstallValidatorTest.php
@covers ::validate

... See full list

File

core/modules/simpletest/src/AssertHelperTrait.php, line 26
Contains \Drupal\simpletest\AssertHelperTrait.

Class

AssertHelperTrait
Provides helper methods for assertions.

Namespace

Drupal\simpletest

Code

protected function castSafeStrings($value) {
  if ($value instanceof MarkupInterface) {
    $value = (string) $value;
  }
  if (is_array($value)) {
    array_walk_recursive($value, function (&$item) {
      if ($item instanceof MarkupInterface) {
        $item = (string) $item;
      }
    });
  }
  return $value;
}