| Conditions | 5 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 45 | 1 | protected static function getForUrl($url) |
|
| 46 | { |
||
| 47 | 1 | $identifier = null; |
|
| 48 | |||
| 49 | 1 | foreach (config('apps.url') as $id => $root) { |
|
| 50 | 1 | $root = preg_replace('#^https?://#', '', $root); |
|
| 51 | 1 | $pattern = '#^https?://'.preg_quote($root, '#').'([\?/].*)?$#'; |
|
| 52 | 1 | if (preg_match($pattern, $url)) { |
|
| 53 | 1 | $len = strlen($root); |
|
| 54 | 1 | if (! isset($length) || $length < $len) { |
|
| 55 | 1 | $length = $len; |
|
| 56 | 1 | $identifier = $id; |
|
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | 1 | return $identifier; |
|
| 62 | } |
||
| 64 |