Schema implements Countable
Interfaces
- Countable
Methods
- __construct() : mixed
- add() : self
- addMetadata() : self
- Adds metadata to a given definition.
- count() : int
- definitions() : array<string|int, Definition>
- entries() : array<string|int, Reference>
- findDefinition() : Definition|null
- fromArray() : self
- fromPipeline() : self
- Detecting schema from the pipeline has several disadvantages.
- get() : Definition
- getDefinition() : Definition
- gracefulRemove() : self
- Gracefully remove entries from schema without throwing an exception if entry does not exist.
- keep() : self
- makeNullable() : self
- Makes all schema definitions nullable.
- merge() : self
- normalize() : array<string|int, mixed>
- nullable() : self
- references() : References
- remove() : self
- rename() : self
- replace() : self
- setMetadata() : self
- Overwrites metadata for a given definition.
Methods
__construct()
public
__construct(Definition ...$definitions) : mixed
Parameters
- $definitions : Definition
add()
public
add(Definition ...$definitions) : self
Parameters
- $definitions : Definition
Return values
selfaddMetadata()
Adds metadata to a given definition.
public
addMetadata(string $definition, string $name, int|string|bool|float|array<string|int, mixed> $value) : self
Parameters
- $definition : string
- $name : string
- $value : int|string|bool|float|array<string|int, mixed>
Tags
Return values
selfcount()
public
count() : int
Return values
intdefinitions()
public
definitions() : array<string|int, Definition>
Return values
array<string|int, Definition>entries()
public
entries() : array<string|int, Reference>
use references() : References instead
Return values
array<string|int, Reference>findDefinition()
public
findDefinition(string|Reference $ref) : Definition|null
Parameters
- $ref : string|Reference
Return values
Definition|nullfromArray()
public
static fromArray(array<string|int, mixed> $definitions) : self
Parameters
- $definitions : array<string|int, mixed>
Return values
selffromPipeline()
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
selfget()
public
get(string|Reference $ref) : Definition
Parameters
- $ref : string|Reference
Tags
Return values
DefinitiongetDefinition()
public
getDefinition(string|Reference $ref) : Definition
please use Schema::get() instead
Parameters
- $ref : string|Reference
Tags
Return values
DefinitiongracefulRemove()
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
selfkeep()
public
keep(string|Reference ...$entries) : self
Parameters
- $entries : string|Reference
Return values
selfmakeNullable()
Makes all schema definitions nullable.
public
makeNullable() : self
Return values
selfmerge()
public
merge(self $schema) : self
Parameters
- $schema : self
Return values
selfnormalize()
public
normalize() : array<string|int, mixed>
Return values
array<string|int, mixed>nullable()
public
nullable() : self
use makeNullable instead
Return values
selfreferences()
public
references() : References
Return values
Referencesremove()
public
remove(string|Reference ...$entries) : self
Parameters
- $entries : string|Reference
Return values
selfrename()
public
rename(string|Reference $entry, string $newName) : self
Parameters
- $entry : string|Reference
- $newName : string
Return values
selfreplace()
public
replace(string|Reference $entry, Definition $definition) : self
Parameters
- $entry : string|Reference
- $definition : Definition
Return values
selfsetMetadata()
Overwrites metadata for a given definition.
public
setMetadata(string $definition, Metadata $metadata) : self
Parameters
- $definition : string
- $metadata : Metadata