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 assertions validate values at runtime and throw InvalidArgumentException if the value doesn't match the expected type.
The assert() method returns the validated value with proper type narrowing, enabling static analysis tools like
PHPStan to understand the resulting type. This provides IDE autocompletion and catches type errors during analysis.

<?php

$value = takeFromUser(); // $value is type mixed here

$stringValue = type_string()->assert($value); 

// $valueString is type string here, it's called types narrowing 

Read more about types narrowing


Assert class-string values. Validates that the string is a valid class name, optionally implementing a specific class or interface.

Documentation

Code

play
<?php

declare(strict_types=1);

use function Flow\Types\DSL\type_class_string;

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

echo 'Assert class string: ' . type_class_string()->assert(\DateTimeImmutable::class) . "\n";
echo 'Assert with parent: ' . type_class_string(\DateTimeInterface::class)->assert(\DateTimeImmutable::class) . "\n";

Contributors

Join us on GitHub external resource
scroll back to top