Base64UrlSafeEncoder::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 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
/*
3
 * This file is part of the Guarded Authentication package.
4
 *
5
 * (c) Jafar Jabr <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Jafar\Bundle\GuardedAuthenticationBundle\Api\JWTSigner\Base64;
12
13
/**
14
 * Class Base64UrlSafeEncoder.
15
 *
16
 * @author Jafar Jabr <[email protected]>
17
 */
18
class Base64UrlSafeEncoder implements EncoderInterface
19
{
20
    public function encode($data)
21
    {
22
        return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
23
    }
24
25
    public function decode($data)
26
    {
27
        return base64_decode(strtr($data, '-_', '+/'));
28
    }
29
}
30