Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#678)
by Stefano
10:59
created

Base64Encoder::decodeUrlSafe()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.0312

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 7
cts 8
cp 0.875
rs 10
cc 4
nc 4
nop 2
crap 4.0312
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Util;
6
7
final class Base64Encoder
8
{
9 107
    public static function encodeUrlSafe(string $value, bool $padding = false): string
10
    {
11 107
        $result = \base64_encode($value);
12 107
        $result = \str_replace(['+', '/'], ['-', '_'], $result);
13
14 107
        if (!$padding) {
15 101
            $result = \str_replace('=', '', $result);
16
        }
17
18 107
        return $result;
19
    }
20
21 68
    public static function decodeUrlSafe(string $value, bool $strict = true): string
22
    {
23 68
        $value = \str_replace(['-', '_'], ['+', '/'], $value);
24
25 68
        if (0 === \strrpos($value, '=', -1) && 0 !== \strlen($value) % 4) {
26
            $value = \str_pad($value, (\strlen($value) + 3) & ~3, '=');
27
        }
28
29 68
        $result = \base64_decode($value, $strict);
30
31 68
        if (false === $result) {
32 1
            throw new \InvalidArgumentException(\sprintf('The "%s" value failed to be decoded from base64 format.', $value));
33
        }
34
35 67
        return $result;
36
    }
37
}
38