Documentation

Set
in package

Table of Contents

Properties

$values  : array<string|int, mixed>

Methods

add()  : void
Adds a value to the set if it does not already exist.
all()  : array<string|int, mixed>
Returns all values in the set.
find()  : bool
Checks if the value exists in the set.
get()  : string|null
Returns the value if it exists in the set, otherwise returns null.
remove()  : void
Removes a value from the set.
update()  : void
Updates a value in the set by removing the old value and adding the new value.

Properties

$values

private array<string|int, mixed> $values = []

Stores unique values in the set.

Methods

add()

Adds a value to the set if it does not already exist.

public add(string|int|null $value) : void
Parameters
$value : string|int|null

The value to add.

all()

Returns all values in the set.

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

find()

Checks if the value exists in the set.

public find(string|int $target) : bool
Parameters
$target : string|int

The value to search for.

Return values
bool

True if the value exists, false otherwise.

get()

Returns the value if it exists in the set, otherwise returns null.

public get(string|int $target) : string|null
Parameters
$target : string|int

The value to search for.

Return values
string|null

The found value or null if not found.

remove()

Removes a value from the set.

public remove(string|int $value) : void
Parameters
$value : string|int

The value to remove.

update()

Updates a value in the set by removing the old value and adding the new value.

public update(string|int $oldValue, string|int $newValue) : void
Parameters
$oldValue : string|int

The value to be replaced.

$newValue : string|int

The new value to add.


        
On this page

Search results