public static function Inspector::assertAllRegularExpressionMatch in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 353 - Contains \Drupal\Component\Assertion\Inspector.
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;
}