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 2
2
3
3
namespace jblond \Diff \Renderer \Text ;
4
4
5
+ use RuntimeException ;
5
6
use jblond \Diff \Renderer \MainRendererAbstract ;
6
7
7
8
/**
8
- * Unified diff generator for PHP DiffLib.
9
+ * json diff generator for PHP DiffLib.
9
10
*
10
11
* PHP version 7.3 or greater
11
12
*
@@ -27,37 +28,43 @@ class Json extends MainRendererAbstract
27
28
* value.
28
29
*/
29
30
private $ subOptions = [
30
- 'json ' => JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
31
+ 'json ' => JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR
31
32
];
32
33
33
34
/**
34
- * InlineCli constructor.
35
+ * json constructor.
35
36
*
36
- * @param array $options Custom defined options for the InlineCli diff renderer.
37
+ * @param array $options Custom defined options for the json diff renderer.
37
38
*
38
39
* @see Json::$subOptions
39
40
*/
40
41
public function __construct (array $ options = [])
41
42
{
43
+ if (!extension_loaded ('json ' )) {
44
+ throw new RuntimeException ('json extension is not available ' );
45
+ }
42
46
parent ::__construct ($ this ->subOptions );
43
47
$ this ->setOptions ($ options );
44
48
}
45
49
46
50
/**
51
+ * @inheritDoc
52
+ *
47
53
* @return false|string
48
54
*/
49
55
public function render ()
50
56
{
51
57
$ return = [];
52
58
$ opCodes = $ this ->diff ->getGroupedOpCodes ();
53
59
54
- foreach ($ opCodes as $ key => $ group ) {
60
+ foreach ($ opCodes as $ group ) {
55
61
$ return [] = $ this ->toArray ($ group );
56
62
}
57
63
return json_encode ($ return , $ this ->options ['json ' ]);
58
64
}
59
65
60
66
/**
67
+ * Convert the
61
68
* @param $group
62
69
* @return array
63
70
*/
You can’t perform that action at this time.
0 commit comments