Quotes
extends ResponseBase
in package
Represents a collection of option quotes with associated data.
Table of Contents
Properties
- $_saved_filename : string|null
- $errors : array<string, string>
- Array of errors for failed symbol requests (multi-symbol requests only).
- $next_time : Carbon|null
- Time of the next quote if there is no data in the requested period, but there is data in a subsequent period.
- $prev_time : Carbon|null
- Time of the previous quote if there is no data in the requested period, but there is data in a previous period.
- $quotes : array<string|int, OptionQuote>
- Array of OptionQuote objects.
- $status : string
- Status of the quotes request. Will always be ok when there is data for the quote requested.
- $csv : string
- $html : string
Methods
- __construct() : mixed
- Constructs a new Quotes instance from the given response object.
- __toString() : string
- Returns a string representation of the option quotes collection.
- createMerged() : self
- Create a Quotes object from pre-merged data.
- getCsv() : string
- Get the CSV content of the response.
- getHtml() : string
- Get the HTML content of the response.
- isCsv() : bool
- Check if the response is in CSV format.
- isHtml() : bool
- Check if the response is in HTML format.
- isJson() : bool
- Check if the response is in JSON format.
- saveToFile() : string
- Save CSV/HTML content to a file.
Properties
$_saved_filename
public
string|null
$_saved_filename
= null
The filename where the response was saved (if filename parameter was used).
$errors
Array of errors for failed symbol requests (multi-symbol requests only).
public
array<string, string>
$errors
= []
This property is populated only when using multi-symbol quotes() requests. Each key is the option symbol that failed, and the value is the error message. Empty array means no errors occurred.
$next_time
Time of the next quote if there is no data in the requested period, but there is data in a subsequent period.
public
Carbon|null
$next_time
= null
$prev_time
Time of the previous quote if there is no data in the requested period, but there is data in a previous period.
public
Carbon|null
$prev_time
= null
$quotes
Array of OptionQuote objects.
public
array<string|int, OptionQuote>
$quotes
= []
$status
Status of the quotes request. Will always be ok when there is data for the quote requested.
public
string
$status
= 'no_data'
$csv
protected
string
$csv
The CSV content of the response.
$html
protected
string
$html
The HTML content of the response.
Methods
__construct()
Constructs a new Quotes instance from the given response object.
public
__construct(object $response) : mixed
Parameters
- $response : object
-
The response object containing quotes data.
__toString()
Returns a string representation of the option quotes collection.
public
__toString() : string
Return values
string —Human-readable option quotes summary.
createMerged()
Create a Quotes object from pre-merged data.
public
static createMerged(string $status, array<string|int, OptionQuote> $quotes[, Carbon|null $nextTime = null ][, Carbon|null $prevTime = null ][, array<string, string> $errors = [] ]) : self
This static factory method is used by the concurrent request feature to create a Quotes object from multiple merged responses.
Parameters
- $status : string
-
The overall status ('ok' or 'no_data').
- $quotes : array<string|int, OptionQuote>
-
Array of OptionQuote objects.
- $nextTime : Carbon|null = null
-
Time of next quote if no data (for no_data status).
- $prevTime : Carbon|null = null
-
Time of previous quote if no data (for no_data status).
- $errors : array<string, string> = []
-
Array of errors for failed symbols (symbol => error message).
Return values
self —A new Quotes instance with the merged data.
getCsv()
Get the CSV content of the response.
public
getCsv() : string
Tags
Return values
string —The CSV content.
getHtml()
Get the HTML content of the response.
public
getHtml() : string
Tags
Return values
string —The HTML content.
isCsv()
Check if the response is in CSV format.
public
isCsv() : bool
Return values
bool —True if the response is in CSV format, false otherwise.
isHtml()
Check if the response is in HTML format.
public
isHtml() : bool
Return values
bool —True if the response is in HTML format, false otherwise.
isJson()
Check if the response is in JSON format.
public
isJson() : bool
Return values
bool —True if the response is in JSON format, false otherwise.
saveToFile()
Save CSV/HTML content to a file.
public
saveToFile(string $filename) : string
Parameters
- $filename : string
-
The file path to save to.
Tags
Return values
string —The absolute path of the saved file.