function Inspector::assertAllRegularExpressionMatch
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllRegularExpressionMatch()
- 10 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllRegularExpressionMatch()
- 11.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllRegularExpressionMatch()
Asserts that all members are strings matching a regular expression.
Parameters
string $pattern: Regular expression string to find.
mixed $traversable: Variable to be examined.
Return value
bool TRUE if $traversable can be traversed and all members are strings matching $pattern.
1 call to Inspector::assertAllRegularExpressionMatch()
- InspectorTest::testAssertAllRegularExpressionMatch in core/
tests/ Drupal/ Tests/ Component/ Assertion/ InspectorTest.php - Tests asserting regular expression match.
File
-
core/
lib/ Drupal/ Component/ Assertion/ Inspector.php, line 346
Class
Namespace
Drupal\Component\AssertionCode
public static function assertAllRegularExpressionMatch($pattern, $traversable) {
if (static::assertTraversable($traversable)) {
foreach ($traversable as $member) {
if (!is_string($member)) {
return FALSE;
}
if (!preg_match($pattern, $member)) {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.