1 | <?php |
||
13 | class Encoder extends Converter |
||
14 | { |
||
15 | const UTF16 = self::UTF16BE; |
||
16 | const UTF32 = self::UTF32BE; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $encoding = self::UTF8; |
||
22 | |||
23 | /** |
||
24 | * Encoder constructor. |
||
25 | * |
||
26 | * @param string $encoding |
||
27 | * @throws \Crossjoin\Json\Exception\EncodingNotSupportedException |
||
28 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
29 | */ |
||
30 | public function __construct($encoding = self::UTF8) |
||
34 | |||
35 | /** |
||
36 | * @return string |
||
37 | */ |
||
38 | public function getEncoding() |
||
42 | |||
43 | /** |
||
44 | * @param string $encoding |
||
45 | * |
||
46 | * @throws \Crossjoin\Json\Exception\EncodingNotSupportedException |
||
47 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
48 | */ |
||
49 | public function setEncoding($encoding) |
||
61 | |||
62 | /** |
||
63 | * @param mixed $value |
||
64 | * @param int $options |
||
65 | * @param int $depth |
||
66 | * |
||
67 | * @return string |
||
68 | * @throws \Crossjoin\Json\Exception\NativeJsonErrorException |
||
69 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
70 | * @throws \Crossjoin\Json\Exception\ExtensionRequiredException |
||
71 | * @throws \Crossjoin\Json\Exception\ConversionFailedException |
||
72 | */ |
||
73 | public function encode($value, $options = 0, $depth = 512) |
||
94 | |||
95 | /** |
||
96 | * @param mixed $value |
||
97 | * @param int $options |
||
98 | * @param int $depth |
||
99 | * |
||
100 | * @return string |
||
101 | * @throws \Crossjoin\Json\Exception\NativeJsonErrorException |
||
102 | */ |
||
103 | private function encodePhpGte55($value, $options, $depth) |
||
113 | |||
114 | /** |
||
115 | * @param mixed $value |
||
116 | * @param int $options |
||
117 | * |
||
118 | * @return string |
||
119 | * @throws \Crossjoin\Json\Exception\NativeJsonErrorException |
||
120 | * @throws \Crossjoin\Json\Exception\InvalidArgumentException |
||
121 | */ |
||
122 | private function encodePhpLt55($value, $options) |
||
138 | } |
||
139 |