Completed
Push — master ( 01abf8...56bab1 )
by Andy
02:13
created

Parse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractTwitterUsername() 0 8 3
1
<?php
2
3
namespace mySociety\EveryPoliticianPopolo;
4
5
class Parse
6
{
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