File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,22 @@ public function __toString(): string
3535 return (string )$ this ->encode ();
3636 }
3737
38+ /**
39+ * New json instance
40+ * @param array|string $data
41+ * @return self
42+ */
43+ public function withData (array |string $ data ): self
44+ {
45+ $ inst = new self ();
46+ if (is_array ($ data )) {
47+ $ inst ->data = array_merge ($ this ->data , $ data );
48+ } else {
49+ $ inst ->data = $ this ->decode ($ data );
50+ }
51+ return $ inst ;
52+ }
53+
3854 /**
3955 * Merge array to json array
4056 * @param array $array
@@ -222,7 +238,7 @@ public function validate(): void
222238 if (!is_null ($ error )) {
223239 throw new \Exception ($ error , self ::error ());
224240 }
225- throw new \Exception ('An unexpected Json error has occurred ' , self ::error ());
241+ // throw new \Exception('An unexpected Json error has occurred', self::error());
226242 }
227243
228244 /**
You can’t perform that action at this time.
0 commit comments