function Inspector::assertAllMatch
Same name in other branches
- 9 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllMatch()
- 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllMatch()
- 10 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAllMatch()
Asserts that all members are strings that contain the specified string.
This runs faster than the regular expression equivalent.
Parameters
string $pattern: The needle to find.
mixed $traversable: Variable to examine.
bool $case_sensitive: TRUE to use strstr(), FALSE to use stristr() which is case insensitive.
Return value
bool TRUE if $traversable can be traversed and all members are strings containing $pattern.
2 calls to Inspector::assertAllMatch()
- InspectorTest::testAssertAllMatch in core/
tests/ Drupal/ Tests/ Component/ Assertion/ InspectorTest.php - Tests asserting strstr() or stristr() match.
- PermissionsPerBundle::apply in core/
lib/ Drupal/ Core/ Config/ Action/ Plugin/ ConfigAction/ PermissionsPerBundle.php - Applies the config action.
File
-
core/
lib/ Drupal/ Component/ Assertion/ Inspector.php, line 300
Class
Namespace
Drupal\Component\AssertionCode
public static function assertAllMatch($pattern, $traversable, $case_sensitive = FALSE) {
if (is_iterable($traversable)) {
if ($case_sensitive) {
foreach ($traversable as $member) {
if (!(is_string($member) && strstr($member, $pattern))) {
return FALSE;
}
}
}
else {
foreach ($traversable as $member) {
if (!(is_string($member) && stristr($member, $pattern))) {
return FALSE;
}
}
}
return TRUE;
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.