| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3.072 |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | 2 | public function validate(string $received, string $regex): bool |
|
| 46 | { |
||
| 47 | 2 | $matches = []; |
|
| 48 | |||
| 49 | 2 | $result = preg_match($regex, $received, $matches); |
|
| 50 | |||
| 51 | 2 | if ($result === 0) { |
|
| 52 | 1 | $this->message = "Received value must match regex {$regex}"; |
|
| 53 | 1 | return true; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | if ($result === false) { |
|
|
|
|||
| 57 | $this->message = "Invalid regex provided {$regex}"; |
||
| 58 | return true; |
||
| 59 | } |
||
| 60 | |||
| 61 | 1 | return false; |
|
| 62 | } |
||
| 74 |