@@ -39,7 +39,7 @@ final class Helper
3939 *
4040 * @throws ValidationException
4141 */
42- public static function parse ($ json_string )
42+ public static function parseResponseBody ($ json_string )
4343 {
4444 $ data = static ::decodeJson ($ json_string );
4545
@@ -78,16 +78,53 @@ public static function parseRequestBody($json_string)
7878 }
7979
8080 /**
81- * Checks if a string is a valid JSON API
81+ *
82+ * @deprecated since version 0.9, to be removed in 1.0. Use parseResponseBody() instead
83+ *
84+ * @param string $json_string
85+ *
86+ * @return Document
87+ *
88+ * @throws ValidationException
89+ */
90+ public static function parse ($ json_string )
91+ {
92+ @trigger_error (__METHOD__ . ' is deprecated since version 0.9 and will be removed in 1.0. Use parseResponseBody() instead ' , E_USER_DEPRECATED );
93+
94+ return static ::parseResponseBody ($ json_string );
95+ }
96+
97+ /**
98+ * Checks if a string is a valid JSON API response body
8299 *
83100 * @param string $json_string
84101 * @return bool true, if $json_string contains valid JSON API, else false
85102 */
86- public static function isValid ($ json_string )
103+ public static function isValidResponseBody ($ json_string )
104+ {
105+ try
106+ {
107+ static ::parseResponseBody ($ json_string );
108+ }
109+ catch ( Exception $ e )
110+ {
111+ return false ;
112+ }
113+
114+ return true ;
115+ }
116+
117+ /**
118+ * Checks if a string is a valid JSON API request body
119+ *
120+ * @param string $json_string
121+ * @return bool true, if $json_string contains valid JSON API, else false
122+ */
123+ public static function isValidRequestBody ($ json_string )
87124 {
88125 try
89126 {
90- static ::parse ($ json_string );
127+ static ::parseRequestBody ($ json_string );
91128 }
92129 catch ( Exception $ e )
93130 {
@@ -97,6 +134,21 @@ public static function isValid($json_string)
97134 return true ;
98135 }
99136
137+ /**
138+ * Checks if a string is a valid JSON API
139+ *
140+ * @deprecated since version 0.9, to be removed in 1.0. Use isValidResponseBody() instead
141+ *
142+ * @param string $json_string
143+ * @return bool true, if $json_string contains valid JSON API, else false
144+ */
145+ public static function isValid ($ json_string )
146+ {
147+ @trigger_error (__METHOD__ . ' is deprecated since version 0.9 and will be removed in 1.0. Use parseResponseBody() instead ' , E_USER_DEPRECATED );
148+
149+ return static ::isValidResponseBody ($ json_string );
150+ }
151+
100152 /**
101153 * Decodes a json string
102154 *
0 commit comments