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
Push — master ( 81a457...ca7640 )
by Daniel
03:05
created

helpers.php ➔ length()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
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) === false) {
13
        return false;
14
    }
15
16
    return true;
17
}
18
19
function isValidUrl($domain): bool
20
{
21
    if (filter_var($domain, FILTER_VALIDATE_URL) === false) {
22
        return false;
23
    }
24
25
    return true;
26
}
27
28 View Code Duplication
function starts_with($haystack, $needles): bool
29
{
30 8
    foreach ((array) $needles as $needle) {
31 8
        if ($needle != '' && substr($haystack, 0, length($needle)) === (string) $needle) {
32 8
            return true;
33
        }
34
    }
35
36 7
    return false;
37
}
38
39
/**
40
 * Determine if a given string ends with a given substring.
41
 *
42
 * @param string       $haystack
43
 * @param string|array $needles
44
 *
45
 * @return bool
46
 */
47 View Code Duplication
function ends_with(string $haystack, $needles): bool
48
{
49 3
    foreach ((array) $needles as $needle) {
50 3
        if ((string) $needle === substr($haystack, -length($needle))) {
51 3
            return true;
52
        }
53
    }
54
55 2
    return false;
56
}
57
58
/**
59
 * Returns the portion of string specified by the start and length parameters.
60
 *
61
 * @param string   $string
62
 * @param int      $start
63
 * @param int|null $length
64
 *
65
 * @return string
66
 */
67
function substr(string $string, int $start, int $length = null): string
68
{
69 10
    return mb_substr($string, $start, $length, 'UTF-8');
70
}
71
72
/**
73
 * Return the length of the given string.
74
 *
75
 * @param string $value
76
 *
77
 * @return int
78
 */
79
function length(string $value): int
80
{
81 10
    return mb_strlen($value);
82
}
83
84
/**
85
 * Determine if a given string contains a given substring.
86
 *
87
 * @param string       $haystack
88
 * @param string|array $needles
89
 *
90
 * @return bool
91
 */
92
function str_contains(string $haystack, $needles): bool
93
{
94 10
    foreach ((array) $needles as $needle) {
95 10
        if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
96 10
            return true;
97
        }
98
    }
99
100 6
    return false;
101
}
102