/** * return the array values that match the search regex * * @param array|Traversable $data * the collection of input strings to check * @param string $searchRegex * the regex to match * @return array * returns the elements of $data that match the regex * will be an empty array if no matches found */ public static function againstTraversable($data, $searchRegex) { // robustness! RequireTraversable::checkMixed($data, E4xx_UnsupportedType::class); RequirePcreRegex::check($searchRegex, E4xx_InvalidPcreRegex::class); return self::matchArray($data, $searchRegex); }
/** * @covers ::check * @covers ::checkString * @dataProvider provideInvalidRegexesToCheck * @expectedException GanbaroDigital\Reflection\Exceptions\E4xx_InvalidPcreRegex */ public function testRejectsInvalidRegexesWhenCalledStatically($item) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change RequirePcreRegex::check($item); }