-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Base64.zep
44 lines (37 loc) · 903 Bytes
/
Base64.zep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/
namespace Phalcon\Storage\Serializer;
use InvalidArgumentException;
class Base64 extends AbstractSerializer
{
/**
* Serializes data
*/
public function serialize() -> string
{
if typeof this->data !== "string" {
throw new InvalidArgumentException(
"Data for the serializer must of type string"
);
}
return base64_encode(this->data);
}
/**
* Unserializes data
*/
public function unserialize(var data) -> void
{
if typeof data !== "string" {
throw new InvalidArgumentException(
"Data for the unserializer must of type string"
);
}
let this->data = base64_decode(data);
}
}