name: JsonResponse class_comment: '# * Response represents an HTTP response in JSON format. # * # * Note that this class does not force the returned JSON content to be an # * object. It is however recommended that you do return an object as it # * protects yourself against XSSI and JSON-JavaScript Hijacking. # * # * @see https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/AJAX_Security_Cheat_Sheet.md#always-return-json-with-an-object-on-the-outside # * # * @author Igor Wiedler ' dependencies: [] properties: [] methods: - name: __construct visibility: public parameters: - name: data default: 'null' - name: status default: '200' - name: headers default: '[]' - name: json default: 'false' comment: "# * Response represents an HTTP response in JSON format.\n# *\n# * Note\ \ that this class does not force the returned JSON content to be an\n# * object.\ \ It is however recommended that you do return an object as it\n# * protects yourself\ \ against XSSI and JSON-JavaScript Hijacking.\n# *\n# * @see https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/AJAX_Security_Cheat_Sheet.md#always-return-json-with-an-object-on-the-outside\n\ # *\n# * @author Igor Wiedler \n# */\n# class JsonResponse extends\ \ Response\n# {\n# protected mixed $data;\n# protected ?string $callback = null;\n\ # \n# // Encode <, >, ', &, and \" characters in the JSON, making it also safe\ \ to be embedded into HTML.\n# // 15 === JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP\ \ | JSON_HEX_QUOT\n# public const DEFAULT_ENCODING_OPTIONS = 15;\n# \n# protected\ \ int $encodingOptions = self::DEFAULT_ENCODING_OPTIONS;\n# \n# /**\n# * @param\ \ bool $json If the data is already a JSON string" - name: fromJsonString visibility: public parameters: - name: data - name: status default: '200' - name: headers default: '[]' comment: '# * Factory method for chainability. # * # * Example: # * # * return JsonResponse::fromJsonString(''{"key": "value"}'') # * ->setSharedMaxAge(300); # * # * @param string $data The JSON response string # * @param int $status The response status code (200 "OK" by default) # * @param array $headers An array of response headers' - name: setCallback visibility: public parameters: - name: callback comment: '# * Sets the JSONP callback. # * # * @param string|null $callback The JSONP callback or null to use none # * # * @return $this # * # * @throws \InvalidArgumentException When the callback name is not valid' - name: setJson visibility: public parameters: - name: json comment: '# * Sets a raw string containing a JSON document to be sent. # * # * @return $this' - name: setData visibility: public parameters: - name: data default: '[]' comment: '# * Sets the data to be sent as JSON. # * # * @return $this # * # * @throws \InvalidArgumentException' - name: getEncodingOptions visibility: public parameters: [] comment: '# * Returns options used while encoding data to JSON.' - name: setEncodingOptions visibility: public parameters: - name: encodingOptions comment: '# * Sets options used while encoding data to JSON. # * # * @return $this' - name: update visibility: protected parameters: [] comment: '# * Updates the content and headers according to the JSON data and callback. # * # * @return $this' traits: [] interfaces: []