Flow PHP

Schema implements Countable

FinalYes

Interfaces

Countable

Methods

__construct()  : mixed
add()  : Schema
addMetadata()  : Schema
Adds metadata to a given definition.
count()  : int
definitions()  : array<string, Definition<string|int, mixed>>
entries()  : array<string|int, Reference>
findDefinition()  : null|Definition<string|int, mixed>
fromArray()  : self
fromPipeline()  : self
Detecting schema from the pipeline has several disadvantages.
get()  : Definition<string|int, mixed>
getDefinition()  : Definition<string|int, mixed>
gracefulRemove()  : self
Gracefully remove entries from schema without throwing an exception if entry does not exist.
keep()  : Schema
makeNullable()  : self
Makes all schema definitions nullable.
merge()  : self
normalize()  : array<string|int, array<string|int, mixed>>
nullable()  : Schema
references()  : References
remove()  : Schema
rename()  : Schema
replace()  : Schema
setMetadata()  : Schema
Overwrites metadata for a given definition.

Methods

__construct()

public __construct(Definition<string|int, mixed> ...$definitions) : mixed
Parameters
$definitions : Definition<string|int, mixed>

addMetadata()

Adds metadata to a given definition.

public addMetadata(string $definition, string $name, array<string|int, mixed> $value) : Schema
Parameters
$definition : string
$name : string
$value : array<string|int, mixed>
Tags
throws
SchemaDefinitionNotFoundException
Return values
Schema

count()

public count() : int
Return values
int

definitions()

public definitions() : array<string, Definition<string|int, mixed>>
Return values
array<string, Definition<string|int, mixed>>

entries()

public entries() : array<string|int, Reference>

use references() : References instead

Return values
array<string|int, Reference>

fromArray()

public static fromArray(array<string|int, mixed> $definitions) : self
Parameters
$definitions : array<string|int, mixed>
Return values
self

fromPipeline()

Detecting schema from the pipeline has several disadvantages.

public static fromPipeline(Pipeline $pipeline, FlowContext $context[, int $maxRows = 1000 ]) : self

First of all, it's expensive, it needs to iterate through the pipeline until it detects types of all columns. In some cases, when a given column is null in the first 1k rows it will anyway return incorrect schema since row 1001 might have an actual value. When dealing with schemaless file formats like CSV or JSON even when first 1k rows will carry value of one type, there is zero guarantee that following rows will do the same.

Whenever it's possible, it's recommended to define schema upfront and pass it to the extractor. This way, whatever process would need to use this method, will do just one iteration.

Parameters
$pipeline : Pipeline
$context : FlowContext
$maxRows : int = 1000
Return values
self

gracefulRemove()

Gracefully remove entries from schema without throwing an exception if entry does not exist.

public gracefulRemove(string|Reference ...$entries) : self
Parameters
$entries : string|Reference
Return values
self

makeNullable()

Makes all schema definitions nullable.

public makeNullable() : self
Return values
self

merge()

public merge(self $schema) : self
Parameters
$schema : self
Return values
self

normalize()

public normalize() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>

        
On this page

Search results