| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 1 | protected static function getIdentifierForUrl($url) |
|
| 36 | { |
||
| 37 | 1 | $identifier = null; |
|
| 38 | |||
| 39 | 1 | foreach (config('apps.url') as $id => $root) { |
|
| 40 | 1 | $root = preg_replace('#^https?://#', '', $root); |
|
| 41 | 1 | $pattern = '#^https?://'.preg_quote($root, '#').'([\?/].*)?$#'; |
|
| 42 | 1 | if (preg_match($pattern, $url)) { |
|
| 43 | 1 | $len = strlen($root); |
|
| 44 | 1 | if (! isset($length) || $length < $len) { |
|
| 45 | 1 | $length = $len; |
|
| 46 | 1 | $identifier = $id; |
|
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | 1 | return $identifier; |
|
| 52 | } |
||
| 64 |