You are here

public static function Inspector::assertAllStringable in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllStringable()

Asserts all members are strings or objects with magic __toString() method.

Parameters

mixed $traversable: Variable to be examined.

Return value

bool TRUE if $traversable can be traversed and all members are strings or objects with __toString().

1 call to Inspector::assertAllStringable()
InspectorTest::testAssertAllStringable in core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php
Tests asserting all members are strings or objects with __toString().

File

core/lib/Drupal/Component/Assertion/Inspector.php, line 97
Contains \Drupal\Component\Assertion\Inspector.

Class

Inspector
Generic inspections for the assert() statement.

Namespace

Drupal\Component\Assertion

Code

public static function assertAllStringable($traversable) {
  if (static::assertTraversable($traversable)) {
    foreach ($traversable as $member) {
      if (!static::assertStringable($member)) {
        return FALSE;
      }
    }
    return TRUE;
  }
  return FALSE;
}