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.

UrlSafeBase64   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 4 1
A valid() 0 4 1
A decode() 0 9 2
1
<?php
2
/**
3
 * Url safe base64
4
 *
5
 * @link      http://github.com/tck/zf2-imageresizer for the canonical source repository
6
 * @copyright Copyright (c) 2017 Tobias Knab
7
 * 
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
namespace TckImageResizer\Util;
13
14
/**
15
 * Url safe base64 implementation
16
 * 
17
 * @package TckImageResizer
18
 */
19
class UrlSafeBase64
20
{
21
    /**
22
     * base64 encode
23
     *
24
     * @param string $data data to encode
25
     * @return string encoded data
26
     */
27 6
    public static function encode($data)
28
    {
29 6
        return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
30
    }
31
    
32
    /**
33
     * base64 decode
34
     *
35
     * @param string $data data to decode
36
     * @return string decoded data
37
     */
38 6
    public static function decode($data)
39
    {
40 6
        $rData = strtr($data, '-_', '+/');
41 6
        $rMod4 = strlen($rData) % 4;
42 6
        if ($rMod4) {
43 3
            $rData .= substr('====', $rMod4);
44 3
        }
45 6
        return base64_decode($rData);
46
    }
47
    
48
    /**
49
     * base64 check string
50
     *
51
     * @param string $data data to check
52
     * @return boolean vaild or not
53
     */
54 6
    public static function valid($data)
55
    {
56 6
        return (boolean) preg_match('!^[a-zA-Z0-9\-_]*$!', $data);
57
    }
58
}
59