Menu

## Collection
in package
implements Countable, IteratorAggregate, ArrayAccess

Collection.php : 18

Collection Class

##### Tags

see
  https://www.kotchasan.com/

### Interfaces, Classes and Traits

Countable
IteratorAggregate
ArrayAccess

### Table of Contents

$datas : array<string|int, mixed>
  Holds the class members.
__construct() : mixed
  Create a new collection.
clear() : void
  Clear all data.
count() : int
  Get the count of all data.
get() : mixed
  Get the value at $key, or $default if not found.
getIterator() : ArrayIterator
  Retrieve an external iterator.
has() : bool
  Check if $key exists.
keys() : array<string|int, mixed>
  Get a list of keys.
offsetExists() : bool
  Check if $key exists.
offsetGet() : mixed
  Get the value at $key.
offsetSet() : void
  Set the $value of $key.
offsetUnset() : void
  Remove the item at $key.
remove() : void
  Remove the item at $key.
replace() : void
  Add new items, replacing existing items.
set() : void
  Set the $value of $key.
toArray() : array<string|int, mixed>
  Get all data as an array.

### Properties

#### $datas

Collection.php : 25

Holds the class members.

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

### Methods

#### __construct()

Collection.php : 32

Create a new collection.

`public __construct([array<string|int, mixed> $items = [] ]) : mixed`

##### Parameters

$items : array<string|int, mixed> = []

  The initial members of the Collection.

##### Return values

mixed —

#### clear()

Collection.php : 44

Clear all data.

`public clear() : void`

##### Return values

void —

#### count()

Collection.php : 54

Get the count of all data.

`public count() : int`

##### Return values

int —

#### get()

Collection.php : 68

Get the value at $key, or $default if not found.

`public get(mixed $key[, mixed $default = null ]) : mixed`

##### Parameters

$key : mixed
$default : mixed = null

##### Return values

mixed —

#### getIterator()

Collection.php : 82

Retrieve an external iterator.

`public getIterator() : ArrayIterator`

##### Return values

ArrayIterator —

#### has()

Collection.php : 95

Check if $key exists.

`public has(mixed $key) : bool`

##### Parameters

$key : mixed

##### Return values

bool —

#### keys()

Collection.php : 105

Get a list of keys.

`public keys() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

#### offsetExists()

Collection.php : 121

Check if $key exists.

`public offsetExists(mixed $key) : bool`

##### Parameters

$key : mixed

##### Return values

bool —

#### offsetGet()

Collection.php : 134

Get the value at $key.

`public offsetGet(mixed $key) : mixed`

##### Parameters

$key : mixed

##### Return values

mixed —

#### offsetSet()

Collection.php : 148

Set the $value of $key.

`public offsetSet(mixed $key, mixed $value) : void`

##### Parameters

$key : mixed
$value : mixed

##### Return values

void —

#### offsetUnset()

Collection.php : 161

Remove the item at $key.

`public offsetUnset(mixed $key) : void`

##### Parameters

$key : mixed

##### Return values

void —

#### remove()

Collection.php : 174

Remove the item at $key.

`public remove(mixed $key) : void`

##### Parameters

$key : mixed

##### Return values

void —

#### replace()

Collection.php : 186

Add new items, replacing existing items.

`public replace(array<string|int, mixed> $items) : void`

##### Parameters

$items : array<string|int, mixed>

  array(array($key => $value), array($key => $value), ...)

##### Return values

void —

#### set()

Collection.php : 205

Set the $value of $key.

`public set(mixed $key, mixed $value) : void`

##### Parameters

$key : mixed
$value : mixed

##### Return values

void —

#### toArray()

Collection.php : 215

Get all data as an array.

`public toArray() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

## Search results