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.

helpers.php ➔ str_contains()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 3
nop 2
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\SslCertificate;
4
5 View Code Duplication
function starts_with($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...
6
{
7
    foreach ((array) $needles as $needle) {
8
        if ($needle != '' && mb_strpos($haystack, $needle) === 0) {
9
            return true;
10
        }
11
    }
12
13
    return false;
14
}
15
16
/**
17
 * Determine if a given string ends with a given substring.
18
 *
19
 * @param string $haystack
20
 * @param string|array $needles
21
 *
22
 * @return bool
23
 */
24
function ends_with(string $haystack, $needles): bool
25
{
26
    foreach ((array) $needles as $needle) {
27
        if ((string) $needle === substr($haystack, -length($needle))) {
28
            return true;
29
        }
30
    }
31
32
    return false;
33
}
34
35
/**
36
 * Returns the portion of string specified by the start and length parameters.
37
 *
38
 * @param string  $string
39
 * @param int $start
40
 * @param int|null $length
41
 *
42
 * @return string
43
 */
44
function substr(string $string, int $start, int $length = null): string
45
{
46
    return mb_substr($string, $start, $length, 'UTF-8');
47
}
48
49
/**
50
 * Return the length of the given string.
51
 *
52
 * @param string $value
53
 *
54
 * @return int
55
 */
56
function length(string $value): int
57
{
58
    return mb_strlen($value);
59
}
60
61
/**
62
 * Determine if a given string contains a given substring.
63
 *
64
 * @param string $haystack
65
 * @param string|array $needles
66
 *
67
 * @return bool
68
 */
69 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...
70
{
71
    foreach ((array) $needles as $needle) {
72
        if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
73
            return true;
74
        }
75
    }
76
77
    return false;
78
}
79