Browse Source

Enable adding/removing options to json_encode()

Sometimes you want to add some options. In my case I wanted to encode the data using JSON_FORCE_OBJECT, but there was no way to do it
Alvaro Flaño 6 years ago
parent
commit
93eca5639d
1 changed files with 10 additions and 0 deletions
  1. 10 0
      src/Monolog/Formatter/NormalizerFormatter.php

+ 10 - 0
src/Monolog/Formatter/NormalizerFormatter.php

@@ -375,4 +375,14 @@ class NormalizerFormatter implements FormatterInterface
 
         return $date->format($this->dateFormat);
     }
+    
+    protected function addJsonEncodeOption($option)
+    {
+        $this->jsonEncodeOptions |= $option;
+    }
+    
+    protected function removeJsonEncodeOption($option)
+    {
+        $this->jsonEncodeOptions ^= $option;
+    }
 }