Completed
Push — master ( 121b08...5d0a06 )
by Csaba
18s
created

TwitterNormalizer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A afterNormalization() 0 8 1
1
<?php
2
3
namespace HumanDirect\Socially\Normalizer;
4
5
/**
6
 * Class TwitterNormalizer.
7
 */
8
class TwitterNormalizer extends DefaultNormalizer
9
{
10
    /**
11
     * Replace fb.com domain with facebook.com.
12
     *
13
     * {@inheritdoc}
14
     */
15
    public function afterNormalization(string $url): string
16
    {
17
        $url = parent::afterNormalization($url);
18
19
        // strip @ and #! from the URL, eg. twitter.com/@HumanDirectEU becomes twitter.com/HumanDirectEU
20
        $url = str_replace(['.com/@', '.com/#!/', '.com/share'], '.com/', $url);
21
22
        return rtrim($url, '/');
23
    }
24
}
25