Base64   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 17
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A urlSafeEncode() 0 3 1
A urlSafeDecode() 0 10 2
1
<?php
2
3
namespace Rogierw\RwAcme\Support;
4
5
class Base64
6
{
7
    public static function urlSafeEncode(string $input): string
8
    {
9
        return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
10
    }
11
12
    public static function urlSafeDecode(string $input): string
13
    {
14
        $remainder = strlen($input) % 4;
15
16
        if ($remainder) {
17
            $padlen = 4 - $remainder;
18
            $input .= str_repeat('=', $padlen);
19
        }
20
21
        return base64_decode(strtr($input, '-_', '+/'));
22
    }
23
}
24