PHP Interface Puli\Repository\Api\ResourceCollection

Since: 1.0
Author: Bernhard Schussek ([email protected])
Inheritance: extends Traversabl\Traversable, extends ArrayAcces\ArrayAccess, extends Countabl\Countable
Show file Open project: puli/repository Interface Usage Examples

Public Methods

Method Description
add ( Puli\Repository\Api\Resource\PuliResource $resource ) Adds a resource to the collection.
clear ( ) Removes all resources from the collection.
get ( integer $key ) : Puli\Repository\Api\Resource\PuliResource Returns the resource for a collection key.
getNames ( ) : string[] Returns the names of all resources in the collection.
getPaths ( ) : string[] Returns the paths of all resources in the collection.
has ( integer $key ) : boolean Returns whether a collection key exists.
isEmpty ( ) : boolean Returns whether the collection is empty.
keys ( ) : int[] Returns the keys of the collection.
merge ( Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable $resources ) Merges the given resources into the collection.
remove ( integer $key ) Removes a collection key from the collection.
replace ( Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable $resources ) Replaces the collection contents with the given resources.
set ( integer $key, Puli\Repository\Api\Resource\PuliResource $resource ) Sets a resource at a collection key.
toArray ( ) : Puli\Repository\Api\Resource\PuliResource[] Returns the collection contents as array.

Method Details

add() public method

Adds a resource to the collection.
public add ( Puli\Repository\Api\Resource\PuliResource $resource )
$resource Puli\Repository\Api\Resource\PuliResource The added resource.

clear() public method

Removes all resources from the collection.
public clear ( )

get() public method

Returns the resource for a collection key.
public get ( integer $key ) : Puli\Repository\Api\Resource\PuliResource
$key integer The collection key.
return Puli\Repository\Api\Resource\PuliResource The resource at the key.

getNames() public method

The names are returned in the order of their resources in the collection.
See also: PuliResource::getName
public getNames ( ) : string[]
return string[] The names of the resources in the collection.

getPaths() public method

The paths are returned in the order of their resources in the collection.
See also: PuliResource::getPath
public getPaths ( ) : string[]
return string[] The paths of the resources in the collection.

has() public method

Returns whether a collection key exists.
public has ( integer $key ) : boolean
$key integer The collection key.
return boolean Whether the collection key exists.

isEmpty() public method

Returns whether the collection is empty.
public isEmpty ( ) : boolean
return boolean Returns `true` only if the collection contains no resources.

keys() public method

Returns the keys of the collection.
public keys ( ) : int[]
return int[] The collection keys.

merge() public method

Merges the given resources into the collection.
public merge ( Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable $resources )
$resources Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable The resources to merge into the collection.

remove() public method

Removes a collection key from the collection.
public remove ( integer $key )
$key integer The collection key.

replace() public method

Replaces the collection contents with the given resources.
public replace ( Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable $resources )
$resources Puli\Repository\Api\Resource\PuliResource[] | Traversabl\Traversable The resources to write into the collection.

set() public method

Sets a resource at a collection key.
public set ( integer $key, Puli\Repository\Api\Resource\PuliResource $resource )
$key integer The collection key.
$resource Puli\Repository\Api\Resource\PuliResource The resource to set.

toArray() public method

Returns the collection contents as array.
public toArray ( ) : Puli\Repository\Api\Resource\PuliResource[]
return Puli\Repository\Api\Resource\PuliResource[] The resources in the collection.