Documentation

File extends AbstractStorage
in package

Debug file storage class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
4.0.0

Table of Contents

Constants

FORMATS  = ['csv', 'tsv', 'ndjson']
Supported formats

Properties

$dir  : string|null
Storage dir
$format  : string
Format (csv, tsv or ndjson)

Methods

__construct()  : mixed
Constructor
clear()  : void
Clear all debug data
getDir()  : string|null
Get the storage dir
getFormat()  : string
Get the format
hasDir()  : bool
Has storage dir
prepareEvents()  : array<string|int, mixed>
Prepare events
save()  : void
Save debug data
setDir()  : File
Set the current storage dir
setFormat()  : File
Set the format
appendNdJsonToFile()  : void
Append events to an NDJSON (JSON Lines) file, one self-contained JSON object per line

Constants

FORMATS

Supported formats

protected array<string|int, mixed> FORMATS = ['csv', 'tsv', 'ndjson']

Properties

$dir

Storage dir

protected string|null $dir = null

$format

Format (csv, tsv or ndjson)

protected string $format = 'csv'

Methods

__construct()

Constructor

public __construct(string $dir[, string $format = 'csv' ]) : mixed

Instantiate the file storage object

Parameters
$dir : string
$format : string = 'csv'

clear()

Clear all debug data

public clear() : void

getDir()

Get the storage dir

public getDir() : string|null
Return values
string|null

getFormat()

Get the format

public getFormat() : string
Return values
string

hasDir()

Has storage dir

public hasDir() : bool
Return values
bool

prepareEvents()

Prepare events

public prepareEvents(string $id, string $name, AbstractHandler $handler) : array<string|int, mixed>
Parameters
$id : string
$name : string
$handler : AbstractHandler
Return values
array<string|int, mixed>

setDir()

Set the current storage dir

public setDir(string $dir) : File
Parameters
$dir : string
Tags
throws
Exception
Return values
File

setFormat()

Set the format

public setFormat(string $format) : File
Parameters
$format : string
Tags
throws
InvalidArgumentException
Return values
File

appendNdJsonToFile()

Append events to an NDJSON (JSON Lines) file, one self-contained JSON object per line

protected appendNdJsonToFile(string $filename, array<string|int, mixed> $events) : void

The 'context' field of each event is already a json_encode()'d string (see AbstractStorage::prepareEvents(), shared with the CSV/TSV formats, where it needs to be a flat scalar cell). For NDJSON it's decoded back into a real nested value first, so it comes out as proper nested JSON instead of a doubly-escaped string.

Parameters
$filename : string
$events : array<string|int, mixed>

        
On this page

Search results