Earnings
extends ResponseBase
in package
Class Earnings
Represents a collection of earnings data for stocks and handles the response parsing.
Table of Contents
Properties
- $_saved_filename : string|null
- $earnings : array<string|int, Earning>
- Array of Earning objects representing individual stock earnings data.
- $status : string
- The status of the response. Will always be "ok" when there is data for the symbol requested.
- $csv : string
- $html : string
Methods
- __construct() : mixed
- Constructs a new Earnings object and parses the response data.
- __toString() : string
- Returns a string representation of the earnings collection.
- 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).
$earnings
Array of Earning objects representing individual stock earnings data.
public
array<string|int, Earning>
$earnings
= []
$status
The status of the response. Will always be "ok" when there is data for the symbol 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 Earnings object and parses the response data.
public
__construct(object $response) : mixed
Parameters
- $response : object
-
The raw response object to be parsed.
__toString()
Returns a string representation of the earnings collection.
public
__toString() : string
Return values
string —Human-readable earnings summary.
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.