\League\CsvEscapeFormula

A Formatter to tackle CSV Formula Injection.

Summary

Methods
Properties
Constants
__construct()
getSpecialCharacters()
getEscape()
__invoke()
escapeRecord()
No public properties found
FORMULA_STARTING_CHARS
filterSpecialCharacters()
escapeField()
isStringable()
$special_chars
$escape
N/A
No private methods found
No private properties found
N/A

Constants

FORMULA_STARTING_CHARS

FORMULA_STARTING_CHARS = array('=', '-', '+', '@')

Spreadsheet formula starting character.

Properties

$special_chars

$special_chars : array

Effective Spreadsheet formula starting characters.

Type

array

$escape

$escape : string

Escape character to escape each CSV formula field.

Type

string

Methods

__construct()

__construct(string  $escape = "\t", array<mixed,string>  $special_chars = array()) 

New instance.

Parameters

string $escape

escape character to escape each CSV formula field

array<mixed,string> $special_chars

additional spreadsheet formula starting characters

getSpecialCharacters()

getSpecialCharacters() : array<mixed,string>

Returns the list of character the instance will escape.

Returns

array<mixed,string>

getEscape()

getEscape() 

Returns the escape character.

__invoke()

__invoke(array  $record) 

League CSV formatter hook.

Parameters

array $record

escapeRecord()

escapeRecord(array  $record) 

Escape a CSV record.

Parameters

array $record

filterSpecialCharacters()

filterSpecialCharacters(string  ...$characters) : array<mixed,string>

Filter submitted special characters.

Parameters

string $characters variadic

Throws

\InvalidArgumentException

if the string is not a single character

Returns

array<mixed,string>

escapeField()

escapeField(  $cell) 

Escape a CSV cell.

Parameters

$cell

isStringable()

isStringable(  $value) 

Tell whether the submitted value is stringable.

Parameters

$value