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.
Passed
Push — master ( f5e6b3...c7b627 )
by Christian
02:34
created

StringUtils::obfuscate()   B

Complexity

Conditions 7
Paths 8

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 10
nc 8
nop 4
dl 0
loc 19
rs 8.8333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\Twig\Util;
13
14
final class StringUtils
15
{
16
    /**
17
     * @param string $string
18
     * @param int    $start
19
     * @param int    $end
20
     * @param string $replacement
21
     *
22
     * @return string
23
     */
24
    public static function obfuscate($string, $start = 0, $end = 3, $replacement = '*'): string
25
    {
26
        $len = \strlen($string);
27
28
        if ($start < 0) {
29
            $start += $len;
30
        }
31
        $start = min($start, $len - 1);
32
33
        if ($end < 0) {
34
            $end += $len;
35
        }
36
        $end = min($end, $len - 1);
37
38
        if (0 === $len || $len === $start + 1 || $len === $end + 1 || $len <= $start + $end) {
39
            return $string;
40
        }
41
42
        return substr($string, 0, $start).str_repeat($replacement, $len - $end - $start).substr($string, $len - $end, $end);
43
    }
44
}
45