Lua::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
ccs 0
cts 2
cp 0
rs 10
nc 1
cc 1
eloc 2
nop 1
crap 2
1
<?php
2
3
namespace Vlaswinkel\Lua;
4
5
/**
6
 * Class Lua
7
 *
8
 * @author  Koen Vlaswinkel <[email protected]>
9
 * @package Vlaswinkel\Lua
10
 */
11
class Lua {
12
    public static $luaKeywords = [
13
        'and',
14
        'break',
15
        'do',
16
        'else',
17
        'elseif',
18
        'end',
19
        'false',
20
        'for',
21
        'function',
22
        'if',
23
        'in',
24
        'local',
25
        'nil',
26
        'not',
27
        'or',
28
        'repeat',
29
        'return',
30
        'then',
31
        'true',
32
        'until',
33
        'while',
34
    ];
35
36
    public static function serialize($data) {
37
        return Serializer::encode($data);
38
    }
39
40
    public static function deserialize($data) {
41
        $parser = new Parser(new TokenStream(new InputStream($data)));
42
        return LuaToPhpConverter::convertToPhpValue($parser->parse());
43
    }
44
}