Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
74 | 4 | public function idForUrl($url) |
|
75 | { |
||
76 | 4 | $identifier = null; |
|
77 | |||
78 | 4 | foreach ($this->container['config']['apps.url'] as $id => $root) { |
|
79 | 4 | $root = preg_replace('~^https?://~i', '', $root); |
|
80 | 4 | $pattern = '~^https?://'.preg_quote($root, '~').'([/\?#].*)?$~i'; |
|
81 | 4 | if (preg_match($pattern, $url)) { |
|
82 | 4 | $len = strlen($root); |
|
83 | 4 | if (! isset($length) || $length < $len) { |
|
84 | 4 | $length = $len; |
|
85 | 4 | $identifier = $id; |
|
86 | 4 | } |
|
87 | 4 | } |
|
88 | 4 | } |
|
89 | |||
90 | 4 | return $identifier; |
|
91 | } |
||
92 | } |
||
93 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.