Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
27 | public function encode(array $data, $rootNode=null) |
||
28 | { |
||
29 | // Encode <, >, ', &, and " for RFC4627-compliant JSON. |
||
30 | $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT; |
||
31 | |||
32 | // @codeCoverageIgnoreStart |
||
33 | if (!defined('UNIT_TEST') && version_compare(PHP_VERSION, '5.4.0') >= 0) { |
||
34 | $options = $options | JSON_PRETTY_PRINT; |
||
35 | } |
||
36 | // @codeCoverageIgnoreEnd |
||
37 | |||
38 | if (null !== $rootNode) { |
||
39 | $data = array($rootNode => $data); |
||
40 | } |
||
41 | |||
42 | return json_encode($data, $options); |
||
43 | } |
||
44 | |||
46 |