| 1 | <?php |
||
| 4 | trait GrepFunctions |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * Return all strings in the array that match the given regex. |
||
| 8 | * |
||
| 9 | * @param string|array|\VerbalExpressions\PHPVerbalExpressions\VerbalExpressions|SelvinOrtiz\Utils\Flux\Flux|MarkWilson\VerbalExpression |
||
| 10 | * $pattern |
||
| 11 | * @param array |
||
| 12 | * $input |
||
| 13 | * |
||
| 14 | * @throws \InvalidArgumentException |
||
| 15 | * @return array |
||
| 16 | */ |
||
| 17 | 2 | public function grep($pattern, $input) |
|
| 24 | |||
| 25 | /** |
||
| 26 | * Return all strings in the array that do not match the given regex. |
||
| 27 | * |
||
| 28 | * @param string|array|\VerbalExpressions\PHPVerbalExpressions\VerbalExpressions|SelvinOrtiz\Utils\Flux\Flux|MarkWilson\VerbalExpression |
||
| 29 | * $pattern |
||
| 30 | * @param array |
||
| 31 | * $input |
||
| 32 | * |
||
| 33 | * @throws \InvalidArgumentException |
||
| 34 | * @return array |
||
| 35 | */ |
||
| 36 | 2 | public function grepNotMatching($pattern, $input) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * @param mixed $pattern |
||
| 46 | * @throws \InvalidArgumentException |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | abstract protected function getPatternByType($pattern); |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @param mixed $result |
||
| 53 | * @param string $pattern |
||
| 54 | * |
||
| 55 | * @throws \RuntimeException |
||
| 56 | */ |
||
| 57 | abstract protected function checkResultIsOkOrThrowException($result, $pattern); |
||
| 58 | } |
||
| 59 |