Documentation

LazyString
in package
implements Stringable, JsonSerializable

A string whose value is computed lazily by a callback.

Tags
author

Nicolas Grekas p@tchwork.com

Interfaces, Classes and Traits

Stringable
JsonSerializable

Table of Contents

$value  : mixed
__sleep()  : array<string|int, mixed>
__toString()  : string
fromCallable()  : static
fromStringable()  : static
isStringable()  : bool
Tells whether the provided value can be cast to string.
jsonSerialize()  : string
resolve()  : string
Casts scalars and stringable objects to strings.
__construct()  : mixed
getPrettyName()  : string

Properties

Methods

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__toString()

public __toString() : string
Return values
string

fromCallable()

public static fromCallable(callable|array<string|int, mixed> $callback, mixed ...$arguments) : static
Parameters
$callback : callable|array<string|int, mixed>

A callable or a [Closure, method] lazy-callable

$arguments : mixed
Return values
static

fromStringable()

public static fromStringable(string|int|float|bool|Stringable $value) : static
Parameters
$value : string|int|float|bool|Stringable
Return values
static

isStringable()

Tells whether the provided value can be cast to string.

public final static isStringable(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

jsonSerialize()

public jsonSerialize() : string
Return values
string

resolve()

Casts scalars and stringable objects to strings.

public final static resolve(object|string|int|float|bool $value) : string
Parameters
$value : object|string|int|float|bool
Tags
throws
TypeError

When the provided value is not stringable

Return values
string

__construct()

private __construct() : mixed
Return values
mixed

getPrettyName()

private static getPrettyName(callable $callback) : string
Parameters
$callback : callable
Return values
string

Search results