Base64UrlSafeEncoder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 10
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 3 1
A decode() 0 3 1
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