Pipe
    
            
            in package
            
        
    
    
    
FinalYes
A Pipe wraps an intial value and pipes it through any function which modifies it. The resulting value can be accessed at the end.
Example:
echo (new Pipe('NOW')) // wrap initial value
(strtolower(...)) // map through strtolower() => 'now'
->new(DateTimeImmutable::class, Pipe::PLACEHOLDER, new DateTimeZone('UTC')) // create class
->format("Y_m_d") // calls 'format' method => '2025_01_01' (that was 'now' not long ago...)
(str_replace(...), '_', '-') // => '2025-01-01'
(explode(...), '-', Pipe::PLACEHOLDER, 2) // => ['2025', '01-01']
->get(0) // => '2025'
(intval(...)) // => 2025 (still wrapped)
(fn($x) => $x + 1) // => 2026
->value; // unwrap => 2026
// prints: 2026
Tags
Table of Contents
Constants
- PLACEHOLDER = \nixn\php\Partial::PLACEHOLDER
Properties
- $value : mixed
Methods
- __call() : self
- __construct() : mixed
- __invoke() : self
- __toString() : string
- get() : self
- Returns the class field or array element with key `$key`.
- new() : self
- calls `new $class(...)` with the current value placed last or to the first PLACEHOLDER argument (only once!)
- set() : self
- Sets the class field or array element with key `$key` to `$value`.
Constants
PLACEHOLDER
    public
        mixed
    PLACEHOLDER
    = \nixn\php\Partial::PLACEHOLDER
    
    
    
    
Properties
$value
        public
            mixed
    $value
    
    
    
    
    
    
Methods
__call()
    public
                    __call(string $method, array<string|int, mixed> $args) : self
    Parameters
- $method : string
- $args : array<string|int, mixed>
Return values
self__construct()
    public
                    __construct(mixed $value) : mixed
    Parameters
- $value : mixed
__invoke()
    public
                    __invoke(callable $callable, mixed ...$args) : self
    Parameters
- $callable : callable
- $args : mixed
Return values
self__toString()
    public
                    __toString() : string
    Return values
stringget()
Returns the class field or array element with key `$key`.
    public
                    get(string|int $key[, bool $array_access = false ]) : self
    Parameters
- $key : string|int
- 
                    the key. When it is an integer, array access is used automatically. 
- $array_access : bool = false
- 
                    whether to use array access 
Tags
Return values
selfnew()
calls `new $class(...)` with the current value placed last or to the first PLACEHOLDER argument (only once!)
    public
                    new(class-string $class, mixed ...$args) : self
    Parameters
- $class : class-string
- $args : mixed
Tags
Return values
selfset()
Sets the class field or array element with key `$key` to `$value`.
    public
                    set(string|int $key, mixed $value[, bool $array_access = false ]) : self
    Parameters
- $key : string|int
- 
                    the key. When it is an integer, array access is used automatically. 
- $value : mixed
- 
                    the value to be set for the $key.
- $array_access : bool = false
- 
                    whether to use array access