Parser

Parser

Defines the contract for all parsers. A parser receives a single row as input and generates a key => value array with the result.

Methods

Get valid fields

getValidFields(string $type) : array

Get which fields are considered valid in a specific Parser subclass. The mechanism is very simple: valid fields are declared as protected properties in the subclass, and named with a typeValidFields nomenclature.

Example:

class CSVActivateParser extends CSVParser {
    protected $activateValidFields = array(
        "loanid"    => "loanId",
        "activate"  => "activate"
    );
}

In this case 'activate' is the type, so to get this class valid fields:

getValidFields('activate');

Arguments

$type

string

The valid fields type

Response

array

Parse row

parse(array $row) : array
abstract

Abstract function that must be implemented by subclasses to define the parsing strategy.

Arguments

$row

array

The current row to parse

Response

array

Properties


                                
inherited