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   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 13
c 1
b 0
f 0
dl 0
loc 29
ccs 13
cts 14
cp 0.9286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A decodeUrlSafe() 0 15 4
A encodeUrlSafe() 0 10 2
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