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 union type values. Attempts to cast to each type in order until one succeeds.

Documentation

Code

play
<?php

declare(strict_types=1);

use function Flow\Types\DSL\type_integer;
use function Flow\Types\DSL\type_string;
use function Flow\Types\DSL\type_union;

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

$type = type_union(type_string(), type_integer());

echo 'Cast string: ' . $type->cast('hello') . "\n";
echo 'Cast integer: ' . $type->cast(42) . "\n";
echo 'Cast numeric string: ' . $type->cast('123') . "\n";

Contributors

Join us on GitHub external resource
scroll back to top