UrlParser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\Melvin\Parsers;
6
7
class UrlParser
8
{
9
    private const EMPTY_VALUES = [
10
        '',
11
        'n.v.t.',
12
        'n.v.t',
13
    ];
14
15 6
    public function parse(string $url): ?string
16
    {
17 6
        if (in_array($url, self::EMPTY_VALUES, true)) {
18 6
            return null;
19
        }
20
21 6
        if (!str_contains($url, '://')) {
22
            $url = 'https://'.$url;
23
        }
24
25 6
        return $url;
26
    }
27
}
28