|
@@ 83-104 (lines=22) @@
|
| 80 |
|
* @param bool $checkForObjectIdentity |
| 81 |
|
* @param bool $checkForNonObjectIdentity |
| 82 |
|
*/ |
| 83 |
|
public static function assertContains( |
| 84 |
|
$needle, |
| 85 |
|
$haystack, |
| 86 |
|
string $message = '', |
| 87 |
|
bool $ignoreCase = false, |
| 88 |
|
bool $checkForObjectIdentity = true, |
| 89 |
|
bool $checkForNonObjectIdentity = false |
| 90 |
|
): void { |
| 91 |
|
if (is_array($haystack) || is_object($haystack) && $haystack instanceof \Traversable) { |
| 92 |
|
$constraint = self::contains($needle, $checkForObjectIdentity, $checkForNonObjectIdentity); |
| 93 |
|
} elseif (is_string($haystack)) { |
| 94 |
|
if (!is_string($needle)) { |
| 95 |
|
throw InvalidArgumentHelper::factory(1, 'string'); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
$constraint = new StringContains($needle, $ignoreCase); |
| 99 |
|
} else { |
| 100 |
|
throw InvalidArgumentHelper::factory(2, 'array, traversable or string'); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
Assert::assertThat($haystack, $constraint, $message); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
/** |
| 107 |
|
* @param mixed $needle |
|
@@ 114-139 (lines=26) @@
|
| 111 |
|
* @param bool $checkForObjectIdentity |
| 112 |
|
* @param bool $checkForNonObjectIdentity |
| 113 |
|
*/ |
| 114 |
|
public static function assertNotContains( |
| 115 |
|
$needle, |
| 116 |
|
$haystack, |
| 117 |
|
string $message = '', |
| 118 |
|
bool $ignoreCase = false, |
| 119 |
|
bool $checkForObjectIdentity = true, |
| 120 |
|
bool $checkForNonObjectIdentity = false |
| 121 |
|
): void { |
| 122 |
|
if (is_array($haystack) || is_object($haystack) && $haystack instanceof \Traversable) { |
| 123 |
|
$constraint = new LogicalNot( |
| 124 |
|
self::contains($needle, $checkForObjectIdentity, $checkForNonObjectIdentity) |
| 125 |
|
); |
| 126 |
|
} elseif (is_string($haystack)) { |
| 127 |
|
if (!is_string($needle)) { |
| 128 |
|
throw InvalidArgumentHelper::factory(1, 'string'); |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
$constraint = new LogicalNot( |
| 132 |
|
new StringContains($needle, $ignoreCase) |
| 133 |
|
); |
| 134 |
|
} else { |
| 135 |
|
throw InvalidArgumentHelper::factory(2, 'array, traversable or string'); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
Assert::assertThat($haystack, $constraint, $message); |
| 139 |
|
} |
| 140 |
|
|
| 141 |
|
/** |
| 142 |
|
* @param mixed $value |