Completed
Push — master ( 15c40a...010522 )
by kacper
01:57
created

JsonBinaryDecoderFormatter::formatName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
4
namespace MySQLReplication\JsonBinaryDecoder;
5
6
/**
7
 * Class JsonBinaryDecoderFormatter
8
 * @package MySQLReplication\JsonBinaryDecoder
9
 */
10
class JsonBinaryDecoderFormatter
11
{
12
    /**
13
     * @var string
14
     */
15
    public $jsonString = '';
16
17
    /**
18
     * @param $bool
19
     */
20
    public function formatValueBool($bool)
21
    {
22
        $this->jsonString .= var_export($bool, true);
23
    }
24
25
    /**
26
     * @param int $val
27
     */
28
    public function formatValueNumeric($val)
29
    {
30
        $this->jsonString .= $val;
31
    }
32
33
    /**
34
     * @param string $val
35
     */
36
    public function formatValue($val)
37
    {
38
        $this->jsonString .= '"' . $val . '"';
39
    }
40
41
    public function formatEndObject()
42
    {
43
        $this->jsonString .= '}';
44
    }
45
46
    public function formatBeginArray()
47
    {
48
        $this->jsonString .= '[';
49
    }
50
51
    public function formatEndArray()
52
    {
53
        $this->jsonString .= ']';
54
    }
55
56
    public function formatBeginObject()
57
    {
58
        $this->jsonString .= '{';
59
    }
60
61
    public function formatNextEntry()
62
    {
63
        $this->jsonString .= ',';
64
    }
65
66
    /**
67
     * @param string $name
68
     */
69
    public function formatName($name)
70
    {
71
        $this->jsonString .= '"' . $name . '":';
72
    }
73
74
    public function formatValueNull()
75
    {
76
        $this->formatValue('null');
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getJsonString()
83
    {
84
        return $this->jsonString;
85
    }
86
}