comparison core/tests/Drupal/Tests/AssertHelperTrait.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\Tests;
4
5 use Drupal\Component\Render\MarkupInterface;
6
7 /**
8 * Provides helper methods for assertions.
9 */
10 trait AssertHelperTrait {
11
12 /**
13 * Casts MarkupInterface objects into strings.
14 *
15 * @param string|array $value
16 * The value to act on.
17 *
18 * @return mixed
19 * The input value, with MarkupInterface objects casted to string.
20 */
21 protected static function castSafeStrings($value) {
22 if ($value instanceof MarkupInterface) {
23 $value = (string) $value;
24 }
25 if (is_array($value)) {
26 array_walk_recursive($value, function (&$item) {
27 if ($item instanceof MarkupInterface) {
28 $item = (string) $item;
29 }
30 });
31 }
32 return $value;
33 }
34
35 }