Passed
Push — master ( ca3291...6392a2 )
by Jasper
02:29
created

UrlParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 19
ccs 6
cts 6
cp 1
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, '://')) {
0 ignored issues
show
Bug introduced by
It seems like $url can also be of type null; however, parameter $haystack of str_contains() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
        if (!str_contains(/** @scrutinizer ignore-type */ $url, '://')) {
Loading history...
22 6
            $url = 'https://'.$url;
23
        }
24
25 6
        return $url;
26
    }
27
}
28