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::valid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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