Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 1.35 KB

convertible.md

File metadata and controls

80 lines (58 loc) · 1.35 KB

Convertible

The following interfaces are defined to easy the process of creating/converting collections/collection items to basic PHP types.

fromIterable

This interface defines how to create a collection item from an iterable:

interface FromIterable
{
    public static function fromIterable(iterable $data): self|static;
}

fromArray

This interface defines how to create a collection item from an array:

interface FromArray
{
    public static function fromArray(array $data): self|static;
}

toArray

This interface defines how to convert a collection item (or a collection itself) to an array:

interface ToArray
{
    public function toArray(): array;
}

fromInt

This interface defines how to create a collection item from an integer:

interface FromInt
{
    public static function fromInt(int $value): self|static;
}

toInt

This interface defines how to convert a collection item to an integer:

interface ToInt
{
    public function toInt(): int;
}

fromString

This interface defines how to create a collection item from a string:

interface FromString
{
    public static function fromString(string $value): self|static;
}

toString

This interface defines how to convert a collection item to a string:

interface ToString
{
    public function toString(): string;
}