• PHP reference
  • Sandbox
  • Storage

Collection

class Sandbox\Storage\Collection

Class Collection.

Key-value storage collection.

Properties

string $type

string $prefix

Storage $storage

Methods

__construct(Storage $storage, string $type = null)

Collection constructor.

Parameters

boolean|CollectionItem get(integer $id, boolean $raw = false)

Get an item from the collection by ID.

Parameters

  • integer $id
  • boolean $raw

Return Value

boolean exists($id)

Check if an item with that ID exists in the collection.

Parameters

  • $id

Return Value

  • boolean

integer|boolean add($value)

Add a value to the collection and use auto increment for the ID.

Returns the ID of the new item as an integer when successful, otherwise returns bool false.

Parameters

  • $value

Return Value

  • integer|boolean

CollectionItem[] all(boolean $descending = false, boolean $raw = false, integer $after = null)

Return an array with all the items in the collection, with the ID as the array key.

Parameters

  • boolean $descending
  • boolean $raw
  • integer $after

Return Value

integer count()

Returns the number of items in this collection.

Return Value

  • integer

boolean set($id, $value)

Set a item in the collection with a specific ID.

Parameters

  • $id
  • $value

Return Value

  • boolean

boolean update($id, $value)

Set a item in the collection with a specific ID.

Parameters

  • $id
  • $value

Return Value

  • boolean

boolean delete($id)

Delete an item from the collection.

Note that this internally only renamed the key to <prefix>-<id>-del, so that it is not retrievable through this class anymore, but it still exists in the database.

Parameters

  • $id

Return Value

  • boolean