mediatekformation

CsvEncoder
in package
implements EncoderInterface, DecoderInterface

Encodes CSV data.

Tags
author

Kévin Dunglas dunglas@gmail.com

author

Oliver Hoff oliver@hofff.com

Interfaces, Classes, Traits and Enums

EncoderInterface
DecoderInterface

Table of Contents

AS_COLLECTION_KEY  = 'as_collection'
DELIMITER_KEY  = 'csv_delimiter'
ENCLOSURE_KEY  = 'csv_enclosure'
ESCAPE_CHAR_KEY  = 'csv_escape_char'
ESCAPE_FORMULAS_KEY  = 'csv_escape_formulas'
FORMAT  = 'csv'
HEADERS_KEY  = 'csv_headers'
KEY_SEPARATOR_KEY  = 'csv_key_separator'
NO_HEADERS_KEY  = 'no_headers'
OUTPUT_UTF8_BOM_KEY  = 'output_utf8_bom'
FORMULAS_START_CHARACTERS  = ['=', '-', '+', '@', "\t", "\r"]
UTF8_BOM  = ""
$defaultContext  : mixed
__construct()  : mixed
decode()  : mixed
Decodes a string into PHP data.
encode()  : string
Encodes data into the given format.
supportsDecoding()  : bool
Checks whether the deserializer can decode from given format.
supportsEncoding()  : bool
Checks whether the serializer can encode to given format.
extractHeaders()  : array<string|int, string>
flatten()  : mixed
Flattens an array and generates keys including the path.
getCsvOptions()  : array<string|int, mixed>

Constants

AS_COLLECTION_KEY

public mixed AS_COLLECTION_KEY = 'as_collection'

DELIMITER_KEY

public mixed DELIMITER_KEY = 'csv_delimiter'

ENCLOSURE_KEY

public mixed ENCLOSURE_KEY = 'csv_enclosure'

ESCAPE_CHAR_KEY

public mixed ESCAPE_CHAR_KEY = 'csv_escape_char'

ESCAPE_FORMULAS_KEY

public mixed ESCAPE_FORMULAS_KEY = 'csv_escape_formulas'

HEADERS_KEY

public mixed HEADERS_KEY = 'csv_headers'

KEY_SEPARATOR_KEY

public mixed KEY_SEPARATOR_KEY = 'csv_key_separator'

NO_HEADERS_KEY

public mixed NO_HEADERS_KEY = 'no_headers'

OUTPUT_UTF8_BOM_KEY

public mixed OUTPUT_UTF8_BOM_KEY = 'output_utf8_bom'

FORMULAS_START_CHARACTERS

private mixed FORMULAS_START_CHARACTERS = ['=', '-', '+', '@', "\t", "\r"]

Properties

$defaultContext

private mixed $defaultContext = [self::DELIMITER_KEY => ',', self::ENCLOSURE_KEY => '"', self::ESCAPE_CHAR_KEY => '', self::ESCAPE_FORMULAS_KEY => false, self::HEADERS_KEY => [], self::KEY_SEPARATOR_KEY => '.', self::NO_HEADERS_KEY => false, self::AS_COLLECTION_KEY => false, self::OUTPUT_UTF8_BOM_KEY => false]

Methods

__construct()

public __construct([array<string|int, mixed> $defaultContext = [] ][, string $enclosure = '"' ][, string $escapeChar = '' ][, string $keySeparator = '.' ][, bool $escapeFormulas = false ]) : mixed
Parameters
$defaultContext : array<string|int, mixed> = []
$enclosure : string = '"'
$escapeChar : string = ''
$keySeparator : string = '.'
$escapeFormulas : bool = false
Return values
mixed

decode()

Decodes a string into PHP data.

public decode(mixed $data, mixed $format[, array<string|int, mixed> $context = [] ]) : mixed
Parameters
$data : mixed

Data to decode

$format : mixed

Format name

$context : array<string|int, mixed> = []

Options that decoders have access to

The format parameter specifies which format the data is in; valid values depend on the specific implementation. Authors implementing this interface are encouraged to document which formats they support in a non-inherited phpdoc comment.

Return values
mixed

encode()

Encodes data into the given format.

public encode(mixed $data, mixed $format[, array<string|int, mixed> $context = [] ]) : string
Parameters
$data : mixed

Data to encode

$format : mixed

Format name

$context : array<string|int, mixed> = []

Options that normalizers/encoders have access to

Return values
string

supportsDecoding()

Checks whether the deserializer can decode from given format.

public supportsDecoding(mixed $format) : bool
Parameters
$format : mixed

Format name

Return values
bool

supportsEncoding()

Checks whether the serializer can encode to given format.

public supportsEncoding(mixed $format) : bool
Parameters
$format : mixed

Format name

Return values
bool

extractHeaders()

private extractHeaders(iteratable<string|int, mixed> $data) : array<string|int, string>
Parameters
$data : iteratable<string|int, mixed>
Return values
array<string|int, string>

flatten()

Flattens an array and generates keys including the path.

private flatten(iteratable<string|int, mixed> $array, array<string|int, mixed> &$result, string $keySeparator[, string $parentKey = '' ][, bool $escapeFormulas = false ]) : mixed
Parameters
$array : iteratable<string|int, mixed>
$result : array<string|int, mixed>
$keySeparator : string
$parentKey : string = ''
$escapeFormulas : bool = false
Return values
mixed

getCsvOptions()

private getCsvOptions(array<string|int, mixed> $context) : array<string|int, mixed>
Parameters
$context : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results