Since: 9.1.0

class EscapeFormula (View source)

A League CSV formatter to tackle CSV Formula Injection.

Constants

FORMULA_STARTING_CHARS

Spreadsheet formula starting character.

Properties

protected array $special_chars

Effective Spreadsheet formula starting characters.

protected string $escape

Escape character to escape each CSV formula field.

Methods

__construct(string $escape = "\t", array $special_chars = [])

New instance.

string[]
filterSpecialCharacters(array $characters)

Filter submitted special characters.

string[]
getSpecialCharacters()

Returns the list of character the instance will escape.

string
getEscape()

Returns the escape character.

__invoke(array $record)

League CSV formatter hook.

array
escapeRecord(array $record)

Escape a CSV record.

string
escapeField($cell)

Escape a CSV cell.

bool
isStringable($value)

Tell whether the submitted value is stringable.

Details

__construct(string $escape = "\t", array $special_chars = [])

New instance.

Parameters

string $escape

escape character to escape each CSV formula field

array $special_chars

additional spreadsheet formula starting characters

protected string[] filterSpecialCharacters(array $characters)

Filter submitted special characters.

Parameters

array $characters

Return Value

string[]

Exceptions

InvalidArgumentException

string[] getSpecialCharacters()

Returns the list of character the instance will escape.

Return Value

string[]

string getEscape()

Returns the escape character.

Return Value

string

__invoke(array $record)

League CSV formatter hook.

Parameters

array $record

See also

escapeRecord

array escapeRecord(array $record)

Escape a CSV record.

Parameters

array $record

Return Value

array

protected string escapeField($cell)

Escape a CSV cell.

Parameters

$cell

Return Value

string

protected bool isStringable($value)

Tell whether the submitted value is stringable.

Parameters

$value

Return Value

bool