Schema implements Countable
Interfaces
- Countable
Methods
- __construct() : mixed
- add() : Schema
- addAfter() : Schema
- Inserts definitions immediately after an existing column.
- addBefore() : Schema
- Inserts definitions immediately before an existing column.
- addMetadata() : Schema
- Adds metadata to a given definition.
- count() : int
- definitions() : array<string, Definition<string|int, mixed>>
- findDefinition() : null|Definition<string|int, mixed>
- fromArray() : self
- get() : Definition<string|int, mixed>
- gracefulRemove() : self
- Gracefully remove columns from schema without throwing an exception if column does not exist.
- insertAt() : Schema
- Inserts definitions at an explicit position. Index 0 prepends, an index equal to the number of definitions appends.
- isSame() : bool
- Column order is part of a Schema's identity - two schemas holding the same columns in a different order describe two different row shapes, and a row is stored in Schema order.
- keep() : Schema
- makeNullable() : self
- Makes all schema definitions nullable.
- matchOrderTo() : self
- Columns present in both schemas are emitted in $authority's order; columns only in $this are appended unchanged. Nothing is added, dropped or widened, and no type is rewritten - a column whose type orders its own elements differently is a different type, not a reorderable one.
- merge() : self
- missingFrom() : array<int, string>
- The names of this schema's columns $header does not hold.
- moveAfter() : Schema
- Moves an existing column to immediately after another column, preserving its definition.
- moveBefore() : Schema
- Moves an existing column to immediately before another column, preserving its definition.
- moveTo() : Schema
- Moves an existing column to an explicit position, preserving its definition.
- names() : array<int, string>
- normalize() : array<string|int, array<string|int, mixed>>
- prepend() : Schema
- Inserts definitions at the beginning of the schema.
- put() : self
- Adds $definition, or replaces the definition of the same name in place.
- remove() : Schema
- rename() : Schema
- reorder() : Schema
- Reorders columns by name. Any columns not listed keep their relative order and are appended.
- replace() : Schema
- setMetadata() : Schema
- Overwrites metadata for a given definition.
- sort() : Schema
Methods
__construct()
public
__construct(Definition<string|int, mixed> ...$definitions) : mixed
Parameters
- $definitions : Definition<string|int, mixed>
add()
public
add(Definition<string|int, mixed> ...$definitions) : Schema
Parameters
- $definitions : Definition<string|int, mixed>
Return values
SchemaaddAfter()
Inserts definitions immediately after an existing column.
public
addAfter(string $reference, Definition<string|int, mixed> ...$definitions) : Schema
Parameters
- $reference : string
- $definitions : Definition<string|int, mixed>
Tags
Return values
SchemaaddBefore()
Inserts definitions immediately before an existing column.
public
addBefore(string $reference, Definition<string|int, mixed> ...$definitions) : Schema
Parameters
- $reference : string
- $definitions : Definition<string|int, mixed>
Tags
Return values
SchemaaddMetadata()
Adds metadata to a given definition.
public
addMetadata(string $definition, string $name, array<string|int, mixed>|bool|float|int|string $value) : Schema
Parameters
- $definition : string
- $name : string
- $value : array<string|int, mixed>|bool|float|int|string
Tags
Return values
Schemacount()
public
count() : int
Return values
intdefinitions()
public
definitions() : array<string, Definition<string|int, mixed>>
Return values
array<string, Definition<string|int, mixed>>findDefinition()
public
findDefinition(string $name) : null|Definition<string|int, mixed>
Parameters
- $name : string
Return values
null|Definition<string|int, mixed>fromArray()
public
static fromArray(array<string|int, mixed> $definitions) : self
Parameters
- $definitions : array<string|int, mixed>
Return values
selfget()
public
get(string $name) : Definition<string|int, mixed>
Parameters
- $name : string
Tags
Return values
Definition<string|int, mixed>gracefulRemove()
Gracefully remove columns from schema without throwing an exception if column does not exist.
public
gracefulRemove(string ...$names) : self
Parameters
- $names : string
Return values
selfinsertAt()
Inserts definitions at an explicit position. Index 0 prepends, an index equal to the number of definitions appends.
public
insertAt(int $index, Definition<string|int, mixed> ...$definitions) : Schema
Parameters
- $index : int
- $definitions : Definition<string|int, mixed>
Tags
Return values
SchemaisSame()
Column order is part of a Schema's identity - two schemas holding the same columns in a different order describe two different row shapes, and a row is stored in Schema order.
public
isSame(self $schema) : bool
Parameters
- $schema : self
Return values
boolkeep()
public
keep(string ...$names) : Schema
Parameters
- $names : string
Return values
SchemamakeNullable()
Makes all schema definitions nullable.
public
makeNullable() : self
Return values
selfmatchOrderTo()
Columns present in both schemas are emitted in $authority's order; columns only in $this are appended unchanged. Nothing is added, dropped or widened, and no type is rewritten - a column whose type orders its own elements differently is a different type, not a reorderable one.
public
matchOrderTo(self $authority) : self
Parameters
- $authority : self
Return values
selfmerge()
public
merge(self $schema) : self
Parameters
- $schema : self
Return values
selfmissingFrom()
The names of this schema's columns $header does not hold.
public
missingFrom(array<int, string> $header) : array<int, string>
Parameters
- $header : array<int, string>
Return values
array<int, string>moveAfter()
Moves an existing column to immediately after another column, preserving its definition.
public
moveAfter(string $name, string $reference) : Schema
Parameters
- $name : string
- $reference : string
Tags
Return values
SchemamoveBefore()
Moves an existing column to immediately before another column, preserving its definition.
public
moveBefore(string $name, string $reference) : Schema
Parameters
- $name : string
- $reference : string
Tags
Return values
SchemamoveTo()
Moves an existing column to an explicit position, preserving its definition.
public
moveTo(string $name, int $index) : Schema
The index is the final position of the column in the resulting schema.
Parameters
- $name : string
- $index : int
Tags
Return values
Schemanames()
public
names() : array<int, string>
Return values
array<int, string>normalize()
public
normalize() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>prepend()
Inserts definitions at the beginning of the schema.
public
prepend(Definition<string|int, mixed> ...$definitions) : Schema
Parameters
- $definitions : Definition<string|int, mixed>
Return values
Schemaput()
Adds $definition, or replaces the definition of the same name in place.
public
put(Definition<string|int, mixed> $definition) : self
Parameters
- $definition : Definition<string|int, mixed>
Return values
selfremove()
public
remove(string ...$names) : Schema
Parameters
- $names : string
Return values
Schemarename()
public
rename(string $column, string $newName) : Schema
Parameters
- $column : string
- $newName : string
Return values
Schemareorder()
Reorders columns by name. Any columns not listed keep their relative order and are appended.
public
reorder(string ...$names) : Schema
Parameters
- $names : string
Tags
Return values
Schemareplace()
public
replace(string $column, Definition<string|int, mixed> $definition) : Schema
Parameters
- $column : string
- $definition : Definition<string|int, mixed>
Return values
SchemasetMetadata()
Overwrites metadata for a given definition.
public
setMetadata(string $definition, Metadata $metadata) : Schema
Parameters
- $definition : string
- $metadata : Metadata
Tags
Return values
Schemasort()
public
sort([SortingStrategy $strategy = new AlphabeticalStrategy() ]) : Schema
Parameters
- $strategy : SortingStrategy = new AlphabeticalStrategy()