Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
24 | 27 | private static function validateUrl($url) |
|
25 | { |
||
26 | 27 | if (!is_string($url)) { |
|
27 | 9 | throw new \InvalidArgumentException('Webhook endpoint is not a string'); |
|
28 | } |
||
29 | |||
30 | 18 | $isValid = preg_match('#((https?|ftp)://(\S*?\.\S*?))([\s)\[\]{},;"\':<]|\.\s|$)#i', $url); |
|
31 | |||
32 | 18 | if (!$isValid) { |
|
33 | 6 | throw new \InvalidArgumentException('Webhook endpoint is not a URL'); |
|
34 | } |
||
35 | |||
36 | 12 | return true; |
|
37 | } |
||
38 | |||
57 |