src/Response.php
public function setBodyData($data)
    {
        if (!$data instanceof \Generator) {
            $this->body[static::DEFAULT_DATA_NAME] = $data;
            return $this;
        }
        foreach ($data as $key => $value) {
            $actualKey = $key ?: static::DEFAULT_DATA_NAME;
            $this->body[$actualKey] = $value;
        }
        return $this;
    }
public function setBodyData($data)
    {
        if (!$data instanceof \Generator) {
            $this->body[static::DEFAULT_DATA_NAME] = $data;
            return $this;
        }
        foreach ($data as $key => $value) {
            $actualKey = $key ?: static::DEFAULT_DATA_NAME;
            $this->body[$actualKey] = $value;
        }
        return $this;
    }
public function setBodyData ( $ data ) { if ( ! $ data instanceof \ Generator ) { $ this -> body [ static :: DEFAULT_DATA_NAME ] = $ data ; return $ this ; } foreach ( $ data as $ key => $ value ) { $ actualKey = $ key ? : static :: DEFAULT_DATA_NAME ; $ this -> body [ $ actualKey ] = $ value ; } return $ this ; }
Set the data that is to be returned.

If data is directly returned from an endpoint, it will be attached to
the default data name (usually "data").

@example
return 'hello world'; becomes { "data" => "hello world" }

However, if a Generator is returned, the keys returned will be used
instead.

@example
yield 'hello' => 'world'; becomes { "hello" => "world" }

If no key is given, the default will still be used. This is useful to
provide uniformity in response while adding additional data such as
HATEOAS.

@example
yield 'hello';
yield 'links' => $this->generateLinks();

@param \Generator|mixed $data
@return $this
Set the data that is to be returned .