Conditions | 3 |
Paths | 2 |
Total Lines | 8 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 5 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | 18 | public static function extractTwitterUsername($usernameOrUrl) |
|
8 | { |
||
9 | 18 | $splitUrl = parse_url($usernameOrUrl); |
|
10 | 18 | if (array_key_exists('host', $splitUrl) && $splitUrl['host'] == 'twitter.com') { |
|
11 | 9 | return preg_replace('!^/([^/]+).*!', '\1', $splitUrl['path']); |
|
12 | } |
||
13 | 9 | return ltrim(trim($usernameOrUrl), '@'); |
|
14 | } |
||
15 | } |
||
16 |