Passed
Branch dev (6bb8f6)
by Dispositif
03:01
created

ExternDomains   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 1
b 0
f 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A extractSubDomain() 0 8 2
1
<?php
2
/**
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019/2020 © Philippe M. <[email protected]>
5
 * For the full copyright and MIT license information, please view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Domain;
11
12
use App\Application\Http\ExternHttpClient;
13
14
class ExternDomains
15
{
16
17
    public static function extractSubDomain(string $url): string
18
    {
19
        if (!ExternHttpClient::isWebURL($url)) {
20
            throw new \Exception('string is not an URL');
21
        }
22
        $parseURL = parse_url($url);
23
24
        return str_replace('www.', '', $parseURL['host']);
25
    }
26
27
}
28