File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,7 @@ abstract class Json implements \BNETDocs\Interfaces\View
1313 */
1414 public static function jsonFlags (): int
1515 {
16- return \JSON_PRESERVE_ZERO_FRACTION
17- | \JSON_THROW_ON_ERROR
18- | (\php_sapi_name () == 'cli ' || \CarlBennett \MVC \Libraries \Common::isBrowser (\getenv ('HTTP_USER_AGENT ' )) ? \JSON_PRETTY_PRINT : 0 );
16+ return \JSON_PRESERVE_ZERO_FRACTION | \JSON_THROW_ON_ERROR | self ::prettyPrint ();
1917 }
2018
2119 /**
@@ -27,4 +25,15 @@ public static function mimeType(): string
2725 {
2826 return \sprintf ('%s;charset=utf-8 ' , self ::MIMETYPE_JSON );
2927 }
28+
29+ /**
30+ * Automatically passes the JSON_PRETTY_PRINT flag when using php-cli or when client is a browser.
31+ *
32+ * @return integer The JSON_PRETTY_PRINT flag or zero.
33+ */
34+ private static function prettyPrint (): int
35+ {
36+ return (\php_sapi_name () == 'cli '
37+ || \BNETDocs \Libraries \Core \StringProcessor::isBrowser () ? \JSON_PRETTY_PRINT : 0 );
38+ }
3039}
You can’t perform that action at this time.
0 commit comments