107 lines
3.4 KiB
YAML
107 lines
3.4 KiB
YAML
name: JsonResponse
|
|
class_comment: null
|
|
dependencies:
|
|
- name: Arrayable
|
|
type: class
|
|
source: Illuminate\Contracts\Support\Arrayable
|
|
- name: Jsonable
|
|
type: class
|
|
source: Illuminate\Contracts\Support\Jsonable
|
|
- name: Macroable
|
|
type: class
|
|
source: Illuminate\Support\Traits\Macroable
|
|
- name: InvalidArgumentException
|
|
type: class
|
|
source: InvalidArgumentException
|
|
- name: JsonSerializable
|
|
type: class
|
|
source: JsonSerializable
|
|
- name: BaseJsonResponse
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\JsonResponse
|
|
properties: []
|
|
methods:
|
|
- name: __construct
|
|
visibility: public
|
|
parameters:
|
|
- name: data
|
|
default: 'null'
|
|
- name: status
|
|
default: '200'
|
|
- name: headers
|
|
default: '[]'
|
|
- name: options
|
|
default: '0'
|
|
- name: json
|
|
default: 'false'
|
|
comment: '# * Create a new JSON response instance.
|
|
|
|
# *
|
|
|
|
# * @param mixed $data
|
|
|
|
# * @param int $status
|
|
|
|
# * @param array $headers
|
|
|
|
# * @param int $options
|
|
|
|
# * @param bool $json
|
|
|
|
# * @return void'
|
|
- name: withCallback
|
|
visibility: public
|
|
parameters:
|
|
- name: callback
|
|
default: 'null'
|
|
comment: "# * {@inheritdoc}\n# *\n# * @return static\n# */\n# #[\\Override]\n# public\
|
|
\ static function fromJsonString(?string $data = null, int $status = 200, array\
|
|
\ $headers = []): static\n# {\n# return new static($data, $status, $headers, 0,\
|
|
\ true);\n# }\n# \n# /**\n# * Sets the JSONP callback.\n# *\n# * @param string|null\
|
|
\ $callback\n# * @return $this"
|
|
- name: getData
|
|
visibility: public
|
|
parameters:
|
|
- name: assoc
|
|
default: 'false'
|
|
- name: depth
|
|
default: '512'
|
|
comment: '# * Get the json_decoded data from the response.
|
|
|
|
# *
|
|
|
|
# * @param bool $assoc
|
|
|
|
# * @param int $depth
|
|
|
|
# * @return mixed'
|
|
- name: hasValidJson
|
|
visibility: protected
|
|
parameters:
|
|
- name: jsonError
|
|
comment: "# * {@inheritdoc}\n# *\n# * @return static\n# */\n# #[\\Override]\n# public\
|
|
\ function setData($data = []): static\n# {\n# $this->original = $data;\n# \n\
|
|
# // Ensure json_last_error() is cleared...\n# json_decode('[]');\n# \n# $this->data\
|
|
\ = match (true) {\n# $data instanceof Jsonable => $data->toJson($this->encodingOptions),\n\
|
|
# $data instanceof JsonSerializable => json_encode($data->jsonSerialize(), $this->encodingOptions),\n\
|
|
# $data instanceof Arrayable => json_encode($data->toArray(), $this->encodingOptions),\n\
|
|
# default => json_encode($data, $this->encodingOptions),\n# };\n# \n# if (! $this->hasValidJson(json_last_error()))\
|
|
\ {\n# throw new InvalidArgumentException(json_last_error_msg());\n# }\n# \n#\
|
|
\ return $this->update();\n# }\n# \n# /**\n# * Determine if an error occurred\
|
|
\ during JSON encoding.\n# *\n# * @param int $jsonError\n# * @return bool"
|
|
- name: hasEncodingOption
|
|
visibility: public
|
|
parameters:
|
|
- name: option
|
|
comment: "# * {@inheritdoc}\n# *\n# * @return static\n# */\n# #[\\Override]\n# public\
|
|
\ function setEncodingOptions($options): static\n# {\n# $this->encodingOptions\
|
|
\ = (int) $options;\n# \n# return $this->setData($this->getData());\n# }\n# \n\
|
|
# /**\n# * Determine if a JSON encoding option is set.\n# *\n# * @param int \
|
|
\ $option\n# * @return bool"
|
|
traits:
|
|
- Illuminate\Contracts\Support\Arrayable
|
|
- Illuminate\Contracts\Support\Jsonable
|
|
- Illuminate\Support\Traits\Macroable
|
|
- InvalidArgumentException
|
|
- JsonSerializable
|
|
interfaces: []
|