GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch ci-improvements (db65bf)
by Daniel
01:43
created

helpers.php ➔ isValidFqdn()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace LiquidWeb\SslCertificate;
4
5
function verifyWebUrl(string $protocol) : bool
6
{
7
    return in_array($protocol, [null, 'http', 'https']);
8
}
9
10
function isValidFqdn($domain): bool
11
{
12
    if (!filter_var($domain, FILTER_VALIDATE_DOMAIN)) {
13
        return false;
14
    }
15
    return true;
16
}
17
18
function isValidUrl($domain): bool
19
{
20
    if (!filter_var($domain, FILTER_VALIDATE_URL)) {
21
        return false;
22
    }
23
    return true;
24
}
25
26 View Code Duplication
function starts_with($haystack, $needles): bool
1 ignored issue
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
{
28
    foreach ((array) $needles as $needle) {
29
        if ($needle != '' && mb_strpos($haystack, $needle) === 0) {
30
            return true;
31
        }
32
    }
33
34
    return false;
35
}
36
37
/**
38
 * Determine if a given string ends with a given substring.
39
 *
40
 * @param string       $haystack
41
 * @param string|array $needles
42
 *
43
 * @return bool
44
 */
45
function ends_with(string $haystack, $needles): bool
46
{
47
    foreach ((array) $needles as $needle) {
48
        if ((string) $needle === substr($haystack, -length($needle))) {
49
            return true;
50
        }
51
    }
52
53
    return false;
54
}
55
56
/**
57
 * Returns the portion of string specified by the start and length parameters.
58
 *
59
 * @param string   $string
60
 * @param int      $start
61
 * @param int|null $length
62
 *
63
 * @return string
64
 */
65
function substr(string $string, int $start, int $length = null): string
66
{
67
    return mb_substr($string, $start, $length, 'UTF-8');
68
}
69
70
/**
71
 * Return the length of the given string.
72
 *
73
 * @param string $value
74
 *
75
 * @return int
76
 */
77
function length(string $value): int
78
{
79
    return mb_strlen($value);
80
}
81
82
/**
83
 * Determine if a given string contains a given substring.
84
 *
85
 * @param string       $haystack
86
 * @param string|array $needles
87
 *
88
 * @return bool
89
 */
90 View Code Duplication
function str_contains(string $haystack, $needles): bool
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
91
{
92
    foreach ((array) $needles as $needle) {
93
        if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
94
            return true;
95
        }
96
    }
97
98
    return false;
99
}
100