base64_urlsafe_decode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
namespace ArcherZdip\LaravelApiAuth\Helper;
3
4
/**
5
 * Return the Base64-encoded version of $data, The alphabet uses '-' instead of '+' and '_' instead of '/'.
6
 *
7
 * @param $data
8
 * @return mixed
9
 */
10
function base64_urlsafe_encode($data)
11
{
12
    return str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($data));
13
}
14
15
16
/**
17
 * Return the Base64-decoded version of $data, The alphabet uses '-' instead of '+' and '_' instead of '/'.
18
 *
19
 * @param $data
20
 * @param null $strict
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $strict is correct as it would always require null to be passed?
Loading history...
21
 * @return bool|string
22
 */
23
function base64_urlsafe_decode($data, $strict = null)
24
{
25
    return base64_decode(str_replace(['-', '_'], ['+', '/'], $data), $strict);
26
}