File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
lib/jblond/Diff/Renderer/Text Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 22
33namespace jblond \Diff \Renderer \Text ;
44
5+ use RuntimeException ;
56use jblond \Diff \Renderer \MainRendererAbstract ;
67
78/**
8- * Unified diff generator for PHP DiffLib.
9+ * json diff generator for PHP DiffLib.
910 *
1011 * PHP version 7.3 or greater
1112 *
@@ -27,37 +28,43 @@ class Json extends MainRendererAbstract
2728 * value.
2829 */
2930 private $ subOptions = [
30- 'json ' => JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
31+ 'json ' => JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR
3132 ];
3233
3334 /**
34- * InlineCli constructor.
35+ * json constructor.
3536 *
36- * @param array $options Custom defined options for the InlineCli diff renderer.
37+ * @param array $options Custom defined options for the json diff renderer.
3738 *
3839 * @see Json::$subOptions
3940 */
4041 public function __construct (array $ options = [])
4142 {
43+ if (!extension_loaded ('json ' )) {
44+ throw new RuntimeException ('json extension is not available ' );
45+ }
4246 parent ::__construct ($ this ->subOptions );
4347 $ this ->setOptions ($ options );
4448 }
4549
4650 /**
51+ * @inheritDoc
52+ *
4753 * @return false|string
4854 */
4955 public function render ()
5056 {
5157 $ return = [];
5258 $ opCodes = $ this ->diff ->getGroupedOpCodes ();
5359
54- foreach ($ opCodes as $ key => $ group ) {
60+ foreach ($ opCodes as $ group ) {
5561 $ return [] = $ this ->toArray ($ group );
5662 }
5763 return json_encode ($ return , $ this ->options ['json ' ]);
5864 }
5965
6066 /**
67+ * Convert the
6168 * @param $group
6269 * @return array
6370 */
You can’t perform that action at this time.
0 commit comments