flow php

UNIFIED DATA PROCESSING FRAMEWORK

composer require flow-php/etl ~0.32.0

ChangelogRelease Cycle

play Try Playground

elephant
extract

Extracts

Read from various data sources.

arrow
transform

Transforms

Shape and optimize for your needs.

arrow
load

Loads

Store and secure in one of many available data sinks.

Examples:

Description

Type casting converts values from one type to another. The cast() method transforms the input value into the target
type, throwing InvalidArgumentException if conversion is impossible. Unlike assertions which validate existing types,
casting actively transforms values (e.g., string "123" becomes integer 123, or "yes" becomes boolean true).

Casting is ideal for normalizing data from external sources like CSV files, API responses, or user input.


Cast list elements between types. Convert arrays of strings to integers or vice versa with automatic element casting.

Documentation

Code

play
<?php

declare(strict_types=1);

use function Flow\Types\DSL\{type_integer, type_list, type_string};

require __DIR__ . '/vendor/autoload.php';

echo 'Strings to ints: ' . json_encode(type_list(type_integer())->cast(['1', '2', '3'])) . "\n";
echo 'Ints to strings: ' . json_encode(type_list(type_string())->cast([10, 20, 30])) . "\n";

Contributors

Join us on GitHub external resource
scroll back to top