class bigquery_sendcsv_service

Methods

static string
get_name()

Gets the name of the service.

array
get_header(mixed $uploadcsvfile)

Gets the header row for the CSV file based on the column mapping configuration.

array
get_fields(mixed $uploadcsvfile)

Gets the list of fields with their names and types based on the column mapping configuration.

string
primarykey()

Gets the primary key for the table.

string
foreignkeys()

Gets the foreign keys for the table.

array
get_options(mixed $uploadcsvfile)

Generates and returns an array of options for configuring a BigQuery table.

array
generate_data(mixed $uploadcsvfile)

Generates and returns an array of data rows mapped based on the column mapping configuration.

static bool
can_execute()

No description

bool
is_valid_data_type(array $data, mixed $uploadcsvfile)

Validates if the data types of the given data entries match the specified types.

bool
execute(uploadcsvfile $uploadcsvfile)

Executes the upload process for a CSV file, including data validation, file preparation, and interaction with the BigQuery API. This method handles exceptions and ensures that the operation complies with the required configuration and logic.

string
save_to_json(array $data)

Saves the given data array to a JSON file, where each element is written as a single JSON object per line.

string
get_filepath(string $extension)

Generates and retrieves the full file path for a given file extension.

static string
get_filename(string $extension)

Generates a unique filename based on the class name and current timestamp.

string
save_to_csv(array $data, array $header)

Saves the provided data to a CSV file with an optional header row.

Details

at line 32
static string get_name()

Gets the name of the service.

Return Value

string

at line 44
array get_header(mixed $uploadcsvfile)

Gets the header row for the CSV file based on the column mapping configuration.

Parameters

mixed $uploadcsvfile

Return Value

array

at line 61
array get_fields(mixed $uploadcsvfile)

Gets the list of fields with their names and types based on the column mapping configuration.

Parameters

mixed $uploadcsvfile

Return Value

array

at line 79
string primarykey()

Gets the primary key for the table.

Return Value

string

at line 89
string foreignkeys()

Gets the foreign keys for the table.

Return Value

string

at line 101
array get_options(mixed $uploadcsvfile)

Generates and returns an array of options for configuring a BigQuery table.

Parameters

mixed $uploadcsvfile

Return Value

array

at line 129
array generate_data(mixed $uploadcsvfile)

Generates and returns an array of data rows mapped based on the column mapping configuration.

Parameters

mixed $uploadcsvfile

Return Value

array

processed data rows with mapped columns

at line 152
static bool can_execute()

No description

Return Value

bool

at line 166
bool is_valid_data_type(array $data, mixed $uploadcsvfile)

Validates if the data types of the given data entries match the specified types.

Parameters

array $data

an array of data rows to validate, where each row contains key-value pairs representing the data

mixed $uploadcsvfile

Return Value

bool

true if all data entries have valid types; false otherwise

at line 232
bool execute(uploadcsvfile $uploadcsvfile)

Executes the upload process for a CSV file, including data validation, file preparation, and interaction with the BigQuery API. This method handles exceptions and ensures that the operation complies with the required configuration and logic.

Parameters

uploadcsvfile $uploadcsvfile

Return Value

bool

true if the operation completes successfully, otherwise an exception is thrown

at line 308
protected string save_to_json(array $data)

Saves the given data array to a JSON file, where each element is written as a single JSON object per line.

Parameters

array $data

the data to be written to the JSON file, with each element representing a row

Return Value

string

the file path of the saved JSON file

Exceptions

Exception

at line 334
protected string get_filepath(string $extension)

Generates and retrieves the full file path for a given file extension.

Parameters

string $extension

the file extension used to construct the filename

Return Value

string

the complete file path including directory and filename

at line 353
static protected string get_filename(string $extension)

Generates a unique filename based on the class name and current timestamp.

Parameters

string $extension

the file extension to be appended to the filename

Return Value

string

The generated filename in the format: ClassName-YYYY-MM-DD-HH-MM-SS.extension

at line 370
protected string save_to_csv(array $data, array $header)

Saves the provided data to a CSV file with an optional header row.

Parameters

array $data

The data to be written to the CSV file. Each element represents a row.

array $header

The header row to be written at the top of the CSV file. Pass an empty array if no header is needed.

Return Value

string

the file path of the generated CSV file

Exceptions

Exception