| Total Complexity | 7 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class BufferJsonEncoder extends AbstractJsonEncoder |
||
| 13 | { |
||
| 14 | /** @var string The encoded JSON in the current step */ |
||
| 15 | private $buffer; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Encodes the entire value as JSON and returns the value as a string. |
||
| 19 | * @return string The encoded JSON |
||
| 20 | */ |
||
| 21 | public function encode() |
||
| 22 | { |
||
| 23 | $json = []; |
||
| 24 | |||
| 25 | foreach ($this as $string) { |
||
| 26 | $json[] = $string; |
||
| 27 | } |
||
| 28 | |||
| 29 | return implode($json); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** {@inheritdoc} */ |
||
| 33 | public function rewind() |
||
| 38 | } |
||
| 39 | |||
| 40 | /** {@inheritdoc} */ |
||
| 41 | public function next() |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Returns the JSON encoded in the current step. |
||
| 50 | * @return string|null The currently encoded JSON or null if the state is not valid |
||
| 51 | */ |
||
| 52 | public function current() |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Writes the JSON output to the step buffer. |
||
| 59 | * @param string $string The JSON string to write |
||
| 60 | * @param int $token The type of the token |
||
| 61 | */ |
||
| 62 | protected function write($string, $token) |
||
| 67 |