public function validate($input) : bool
{
if (is_array($this->haystack)) {
return in_array($input, $this->haystack, $this->identical);
}
if (!is_string($this->haystack)) {
return false;
}
if (empty($input)) {
return false;
}
$enc = mb_detect_encoding($input);
if ($this->identical) {
return mb_strpos($this->haystack, $input, 0, $enc) !== false;
}
return mb_stripos($this->haystack, $input, 0, $enc) !== false;
}
/** * @dataProvider providerForFail * @expectedException \Bluz\Validator\Exception\ValidatorException */ public function testInvalidInChecksShouldThrowInException($input, $haystack, $strict = false) { $v = new In($haystack, $strict); $this->assertFalse($v->validate($input)); $this->assertNotEmpty($v->__toString($input)); $this->assertFalse($v->assert($input)); }