Overview
  • Namespace
  • Class

Namespaces

  • Slim
    • Exception
    • Handlers
      • Strategies
    • Http
    • Interfaces
      • Http

Classes

  • App
  • CallableResolver
  • Collection
  • Container
  • DefaultServicesProvider
  • DeferredCallable
  • Routable
  • Route
  • RouteGroup
  • Router

Traits

  • CallableResolverAwareTrait
  • MiddlewareAwareTrait

Class Collection

Collection

This class provides a common interface used by many other classes in a Slim application that manage "collections" of data that must be inspected and/or manipulated

Slim\Collection implements Slim\Interfaces\CollectionInterface

Direct known subclasses

Slim\Http\Environment, Slim\Http\Headers

Namespace: Slim
Located at Collection.php

Methods summary

public
# __construct( array $items = [] )

Create new collection

Create new collection

Parameters

$items
Pre-populate collection with this key-value array
public
# set( string $key, mixed $value )

Set collection item

Set collection item

Parameters

$key
The data key
$value
The data value

Implementation of

Slim\Interfaces\CollectionInterface::set()
public mixed
# get( string $key, mixed $default = null )

Get collection item for key

Get collection item for key

Parameters

$key
The data key
$default
The default value to return if data key does not exist

Returns

mixed
The key's value, or the default value

Implementation of

Slim\Interfaces\CollectionInterface::get()
public
# replace( array $items )

Add item to collection, replacing existing items with the same data key

Add item to collection, replacing existing items with the same data key

Parameters

$items
Key-value array of data to append to this collection

Implementation of

Slim\Interfaces\CollectionInterface::replace()
public array
# all( )

Get all items in collection

Get all items in collection

Returns

array
The collection's source data

Implementation of

Slim\Interfaces\CollectionInterface::all()
public array
# keys( )

Get collection keys

Get collection keys

Returns

array
The collection's source data keys
public boolean
# has( string $key )

Does this collection have a given key?

Does this collection have a given key?

Parameters

$key
The data key

Returns

boolean

Implementation of

Slim\Interfaces\CollectionInterface::has()
public
# remove( string $key )

Remove item from collection

Remove item from collection

Parameters

$key
The data key

Implementation of

Slim\Interfaces\CollectionInterface::remove()
public
# clear( )

Remove all items from collection

Remove all items from collection

Implementation of

Slim\Interfaces\CollectionInterface::clear()
public boolean
# offsetExists( string $key )

Does this collection have a given key?

Does this collection have a given key?

Parameters

$key
The data key

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed
# offsetGet( string $key )

Get collection item for key

Get collection item for key

Parameters

$key
The data key

Returns

mixed
The key's value, or the default value

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( string $key, mixed $value )

Set collection item

Set collection item

Parameters

$key
The data key
$value
The data value

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( string $key )

Remove item from collection

Remove item from collection

Parameters

$key
The data key

Implementation of

ArrayAccess::offsetUnset()
public integer
# count( )

Get number of items in collection

Get number of items in collection

Returns

integer

Implementation of

Countable::count()
public ArrayIterator
# getIterator( )

Get collection iterator

Get collection iterator

Returns

ArrayIterator

Implementation of

IteratorAggregate::getIterator()

Properties summary

protected array $data

The source data

The source data

# []
API documentation generated by ApiGen