Passed
Branch master (bfd3f5)
by Wilder
01:18
created

Base64EncryptionStrategy::decrypt()   A

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace ElePHPant\Cookie\Strategies\Encryption;
4
5
/**
6
 * Class Base64EncryptionStrategy
7
 *
8
 * Please report bugs on https://github.com/wilderamorim/cookie/issues
9
 *
10
 * @author Wilder Amorim <https://github.com/wilderamorim>
11
 * @link https://www.linkedin.com/in/wilderamorim/
12
 */
13
class Base64EncryptionStrategy implements EncryptionStrategyInterface
14
{
15
    /**
16
     * Encrypt a value using base64 encoding.
17
     *
18
     * @param string $value The value to encrypt.
19
     * @return string       The encrypted value.
20
     */
21
    public function encrypt(string $value): string
22
    {
23
        return base64_encode($value);
24
    }
25
26
    /**
27
     * Decrypt an encrypted value using base64 decoding.
28
     *
29
     * @param string $encryptedValue The encrypted value to decrypt.
30
     * @return string               The decrypted value.
31
     */
32
    public function decrypt(string $encryptedValue): string
33
    {
34
        return base64_decode($encryptedValue);
35
    }
36
37
    /**
38
     * Boot the encryption strategy.
39
     *
40
     * @param array $configs The configuration array.
41
     */
42
    public function boot(array $configs): void
43
    {
44
        // TODO: Implement any necessary initialization logic.
45
    }
46
}
47