Flow PHP

functions.php

Functions

from_rows()

from_rows(Rows ...$rows) : RowsExtractor
Parameters
$rows : Rows
Return values
RowsExtractor

from_array()

from_array(iterable<string|int, mixed> $array[, null|Schema $schema = null ]) : ArrayExtractor
Parameters
$array : iterable<string|int, mixed>
$schema : null|Schema = null
  • @deprecated use withSchema() method instead
Return values
ArrayExtractor

from_cache()

from_cache(string $id[, null|Extractor $fallback_extractor = null ][, bool $clear = false ]) : CacheExtractor
Parameters
$id : string
  • cache id from which data will be extracted
$fallback_extractor : null|Extractor = null
  • extractor that will be used when cache is empty - @deprecated use withFallbackExtractor() method instead
$clear : bool = false
  • clear cache after extraction - @deprecated use withClearOnFinish() method instead
Return values
CacheExtractor

filesystem_cache()

filesystem_cache([Path|string|null $cache_dir = null ][, Filesystem $filesystem = new NativeLocalFilesystem() ][, Serializer $serializer = new NativePHPSerializer() ]) : FilesystemCache
Parameters
$cache_dir : Path|string|null = null
$filesystem : Filesystem = new NativeLocalFilesystem()
$serializer : Serializer = new NativePHPSerializer()
Return values
FilesystemCache

from_sequence_date_period()

from_sequence_date_period(string $entry_name, DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end[, int $options = 0 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : DateTimeInterface
$interval : DateInterval
$end : DateTimeInterface
$options : int = 0
Return values
SequenceExtractor

from_sequence_date_period_recurrences()

from_sequence_date_period_recurrences(string $entry_name, DateTimeInterface $start, DateInterval $interval, int $recurrences[, int $options = 0 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : DateTimeInterface
$interval : DateInterval
$recurrences : int
$options : int = 0
Return values
SequenceExtractor

from_sequence_number()

from_sequence_number(string $entry_name, string|int|float $start, string|int|float $end[, int|float $step = 1 ]) : SequenceExtractor
Parameters
$entry_name : string
$start : string|int|float
$end : string|int|float
$step : int|float = 1
Return values
SequenceExtractor

to_array()

Convert rows to an array and store them in passed array variable.

to_array(array<string|int, mixed> &$array) : ArrayLoader
Parameters
$array : array<string|int, mixed>
Tags
param-out

array<array> $array

Return values
ArrayLoader

to_stream()

to_stream(string $uri[, int|bool $truncate = 20 ][, Output $output = Output::rows ][, string $mode = 'w' ][, Formatter $formatter = new FormatterAsciiTableFormatter() ][, SchemaFormatter $schemaFormatter = new ASCIISchemaFormatter() ]) : StreamLoader
Parameters
$uri : string
$truncate : int|bool = 20
$output : Output = Output::rows
$mode : string = 'w'
$formatter : Formatter = new FormatterAsciiTableFormatter()
$schemaFormatter : SchemaFormatter = new ASCIISchemaFormatter()
Return values
StreamLoader

datetime_entry()

datetime_entry(string $name, DateTimeInterface|string|null $value[, Metadata|null $metadata = null ]) : DateTimeEntry
Parameters
$name : string
$value : DateTimeInterface|string|null
$metadata : Metadata|null = null
Return values
DateTimeEntry

time_entry()

time_entry(string $name, DateInterval|string|null $value[, Metadata|null $metadata = null ]) : TimeEntry
Parameters
$name : string
$value : DateInterval|string|null
$metadata : Metadata|null = null
Return values
TimeEntry

date_entry()

date_entry(string $name, DateTimeInterface|string|null $value[, Metadata|null $metadata = null ]) : DateEntry
Parameters
$name : string
$value : DateTimeInterface|string|null
$metadata : Metadata|null = null
Return values
DateEntry

enum_entry()

enum_entry(string $name, UnitEnum|null $enum[, Metadata|null $metadata = null ]) : EnumEntry
Parameters
$name : string
$enum : UnitEnum|null
$metadata : Metadata|null = null
Return values
EnumEntry

float_entry()

float_entry(string $name, float|int|string|null $value[, Metadata|null $metadata = null ]) : FloatEntry
Parameters
$name : string
$value : float|int|string|null
$metadata : Metadata|null = null
Return values
FloatEntry

json_entry()

json_entry(string $name, array<string|int, mixed>|string|null $data[, Metadata|null $metadata = null ]) : JsonEntry
Parameters
$name : string
$data : array<string|int, mixed>|string|null
$metadata : Metadata|null = null
Return values
JsonEntry

null_entry()

This functions is an alias for creating string entry from null.

null_entry(string $name[, Metadata|null $metadata = null ]) : StringEntry

The main difference between using this function an simply str_entry with second argument null is that this function will also keep a note in the metadata that type might not be final. For example when we need to guess column type from rows because schema was not provided, and given column in the first row is null, it might still change once we get to the second row. That metadata is used to determine if string_entry was created from null or not.

By design flow assumes when guessing column type that null would be a string (the most flexible type).

Parameters
$name : string
$metadata : Metadata|null = null
Return values
StringEntry

xml_entry()

xml_entry(string $name, DOMDocument|string|null $value[, Metadata|null $metadata = null ]) : XMLEntry
Parameters
$name : string
$value : DOMDocument|string|null
$metadata : Metadata|null = null
Return values
XMLEntry

type_structure()

type_structure(array<string, Type<string|int, mixed>> $elements[, bool $nullable = false ]) : StructureType
Parameters
$elements : array<string, Type<string|int, mixed>>
$nullable : bool = false
Return values
StructureType

type_list()

type_list(Type<string|int, mixed> $element[, bool $nullable = false ]) : ListType
Parameters
$element : Type<string|int, mixed>
$nullable : bool = false
Return values
ListType

map_entry()

map_entry(string $name, array<string|int, mixed>|null $value, MapType $mapType[, Metadata|null $metadata = null ]) : MapEntry
Parameters
$name : string
$value : array<string|int, mixed>|null
$mapType : MapType
$metadata : Metadata|null = null
Return values
MapEntry

type_xml()

type_xml([bool $nullable = false ]) : XMLType
Parameters
$nullable : bool = false
Return values
XMLType

type_float()

type_float([bool $nullable = false ][, int $precision = 6 ]) : FloatType
Parameters
$nullable : bool = false
$precision : int = 6
Return values
FloatType

type_object()

type_object(class-string $class[, bool $nullable = false ]) : ObjectType
Parameters
$class : class-string
$nullable : bool = false
Return values
ObjectType

type_array()

type_array([bool $empty = false ][, bool $nullable = false ]) : ArrayType
Parameters
$empty : bool = false
$nullable : bool = false
Return values
ArrayType

type_enum()

type_enum(UnitEnum> $class[, bool $nullable = false ]) : EnumType
Parameters
$class : UnitEnum>
$nullable : bool = false
Return values
EnumType

rows_partitioned()

rows_partitioned(array<string|int, mixed> $rows, array<string|int, mixed>|Partitions $partitions) : Rows
Parameters
$rows : array<string|int, mixed>
$partitions : array<string|int, mixed>|Partitions
Return values
Rows

when()

when(mixed $condition, mixed $then[, mixed $else = null ]) : When
Parameters
$condition : mixed
$then : mixed
$else : mixed = null
Return values
When

cast()

cast(mixed $value, string|Type<string|int, mixed> $type[, Options|null $options = null ]) : Cast
Parameters
$value : mixed
$type : string|Type<string|int, mixed>
$options : Options|null = null
Return values
Cast

array_unpack()

Unpacks each element of an array into a new entry, using the array key as the entry name.

array_unpack(ScalarFunction|array<string|int, mixed> $array[, ScalarFunction|array<string|int, mixed> $skip_keys = [] ][, ScalarFunction|string|null $entry_prefix = null ]) : ArrayUnpack

Before: +--+-------------------+ |id| array| +--+-------------------+ | 1|{"a":1,"b":2,"c":3}| | 2|{"d":4,"e":5,"f":6}| +--+-------------------+

After: +--+-----+-----+-----+-----+-----+ |id|arr.b|arr.c|arr.d|arr.e|arr.f| +--+-----+-----+-----+-----+-----+ | 1| 2| 3| | | | | 2| | | 4| 5| 6| +--+-----+-----+-----+-----+-----+

Parameters
$array : ScalarFunction|array<string|int, mixed>
$skip_keys : ScalarFunction|array<string|int, mixed> = []
$entry_prefix : ScalarFunction|string|null = null
Return values
ArrayUnpack

array_expand()

Expands each value into entry, if there are more than one value, multiple rows will be created.

array_expand(ScalarFunction $function[, ArrayExpand $expand = ArrayExpand::VALUES ]) : ArrayExpand

Array keys are ignored, only values are used to create new rows.

Before: +--+-------------------+ |id| array| +--+-------------------+ | 1|{"a":1,"b":2,"c":3}| +--+-------------------+

After: +--+--------+ |id|expanded| +--+--------+ | 1| 1| | 1| 2| | 1| 3| +--+--------+

Parameters
$function : ScalarFunction
$expand : ArrayExpand = ArrayExpand::VALUES
Return values
ArrayExpand

to_entry()

to_entry(string $name, array<string|int, mixed> $data[, EntryFactory $entryFactory = new EntryFactory() ]) : Entry<mixed, mixed>
Parameters
$name : string
$data : array<string|int, mixed>
$entryFactory : EntryFactory = new EntryFactory()
Return values
Entry<mixed, mixed>

array_to_row()

array_to_row(array<string|int, array<string|int, mixed>>|array<string|int, mixed|string> $data[, EntryFactory $entryFactory = new EntryFactory() ][, array<string|int, Partition>|Partitions $partitions = [] ][, Schema|null $schema = null ]) : Row
Parameters
$data : array<string|int, array<string|int, mixed>>|array<string|int, mixed|string>
$entryFactory : EntryFactory = new EntryFactory()
$partitions : array<string|int, Partition>|Partitions = []
$schema : Schema|null = null
Return values
Row

array_to_rows()

array_to_rows(array<string|int, array<string|int, mixed>>|array<string|int, mixed|string> $data[, EntryFactory $entryFactory = new EntryFactory() ][, array<string|int, Partition>|Partitions $partitions = [] ][, Schema|null $schema = null ]) : Rows
Parameters
$data : array<string|int, array<string|int, mixed>>|array<string|int, mixed|string>
$entryFactory : EntryFactory = new EntryFactory()
$partitions : array<string|int, Partition>|Partitions = []
$schema : Schema|null = null
Return values
Rows

schema_to_json()

schema_to_json(Schema $schema[, bool $pretty = false ]) : string
Parameters
$schema : Schema
$pretty : bool = false
Return values
string

schema_from_json()

schema_from_json(string $schema) : Schema
Parameters
$schema : string
Return values
Schema

schema_metadata()

schema_metadata([array<string, array<string|int, bool|float|int|string>|bool|float|int|string> $metadata = [] ]) : Metadata
Parameters
$metadata : array<string, array<string|int, bool|float|int|string>|bool|float|int|string> = []
Return values
Metadata

int_schema()

Alias for `int_schema`.

int_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

integer_schema()

integer_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

str_schema()

Alias for `string_schema`.

str_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

string_schema()

string_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

bool_schema()

bool_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

float_schema()

float_schema(string $name[, bool $nullable = false ][, int $precision = 6 ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$precision : int = 6
$metadata : Metadata|null = null
Return values
Definition

enum_schema()

enum_schema(string $name, UnitEnum> $type[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$type : UnitEnum>
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

datetime_schema()

datetime_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

time_schema()

time_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

date_schema()

date_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

json_schema()

json_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

xml_schema()

xml_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

xml_element_schema()

xml_element_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

uuid_schema()

uuid_schema(string $name[, bool $nullable = false ][, Metadata|null $metadata = null ]) : Definition
Parameters
$name : string
$nullable : bool = false
$metadata : Metadata|null = null
Return values
Definition

get_type()

get_type(mixed $value) : Type<string|int, mixed>
Parameters
$value : mixed
Return values
Type<string|int, mixed>

print_rows()

print_rows(Rows $rows[, int|bool $truncate = false ][, Formatter|null $formatter = null ]) : string
Parameters
$rows : Rows
$truncate : int|bool = false
$formatter : Formatter|null = null
Return values
string

compare_entries_by_name()

compare_entries_by_name([Order $order = TransformerOrderEntriesOrder::ASC ]) : Comparator
Parameters
$order : Order = TransformerOrderEntriesOrder::ASC
Return values
Comparator

compare_entries_by_type()

compare_entries_by_type([array<string|int, mixed> $priorities = TransformerOrderEntriesTypePriorities::PRIORITIES ][, Order $order = TransformerOrderEntriesOrder::ASC ]) : Comparator
Parameters
$priorities : array<string|int, mixed> = TransformerOrderEntriesTypePriorities::PRIORITIES
$order : Order = TransformerOrderEntriesOrder::ASC
Return values
Comparator

compare_entries_by_type_desc()

compare_entries_by_type_desc([array<string|int, mixed> $priorities = TransformerOrderEntriesTypePriorities::PRIORITIES ]) : Comparator
Parameters
$priorities : array<string|int, mixed> = TransformerOrderEntriesTypePriorities::PRIORITIES
Return values
Comparator

compare_entries_by_type_and_name()

compare_entries_by_type_and_name([array<string|int, mixed> $priorities = TransformerOrderEntriesTypePriorities::PRIORITIES ][, Order $order = TransformerOrderEntriesOrder::ASC ]) : Comparator
Parameters
$priorities : array<string|int, mixed> = TransformerOrderEntriesTypePriorities::PRIORITIES
$order : Order = TransformerOrderEntriesOrder::ASC
Return values
Comparator

is_type()

is_type(array<string|int, string|Type<string|int, mixed>>|Type<string|int, mixed> $type, mixed $value) : bool
Parameters
$type : array<string|int, string|Type<string|int, mixed>>|Type<string|int, mixed>
$value : mixed
Return values
bool

generate_random_int()

generate_random_int([int $start = PHP_INT_MIN ][, int $end = PHP_INT_MAX ][, NativePHPRandomValueGenerator $generator = new NativePHPRandomValueGenerator() ]) : int
Parameters
$start : int = PHP_INT_MIN
$end : int = PHP_INT_MAX
$generator : NativePHPRandomValueGenerator = new NativePHPRandomValueGenerator()
Return values
int

dom_element_to_string()

dom_element_to_string(DOMElement $element[, bool $format_output = false ][, bool $preserver_white_space = false ]) : string|false
Parameters
$element : DOMElement
$format_output : bool = false
$preserver_white_space : bool = false
Return values
string|false

date_interval_to_milliseconds()

date_interval_to_milliseconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

date_interval_to_seconds()

date_interval_to_seconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

date_interval_to_microseconds()

date_interval_to_microseconds(DateInterval $interval) : int
Parameters
$interval : DateInterval
Return values
int

caster()

Advanced type casting mechanism.

caster([Options|null $options = null ]) : Caster

Usage:

caster()->to(type_float(precision: 2))->value("1.1234") // 1.12

Options can be also passed to "to" function to override default options.

caster()->to(type_float(precision: 2), caster_options())->value("1.1234") // 1.12

Parameters
$options : Options|null = null
Return values
Caster

        
On this page

Search results