Skip to content
Craig Manley edited this page Feb 17, 2016 · 3 revisions

Validate\Specs

A Specs object is simply a collection of Spec objects. Specs objects behave as (associative) arrays since they implement the Countable, IteratorAggregate, and ArrayAccess interfaces.

  • Class name: Specs
  • Namespace: Validate
  • This class implements: Countable, IteratorAggregate, ArrayAccess

Methods

__construct

__construct(array $pairs)

The constructor takes an (associative) array of name => value pairs as argument. Typically, values must be Spec objects. For convenience sake, the following non-Spec type values are also allowed:

  • boolean - then these are converted into a Spec object with 'optional' => !$value
  • array - these are used as arguments to create a new Spec object

count

integer count()

Implements countable. Returns the number of Spec objects in the collection.

getIterator

ArrayIterator getIterator()

Implements IteratorAggregate.

offsetSet

void offsetSet($offset, $value)

Implements ArrayAccess.

offsetExists

boolean offsetExists($offset)

Implements ArrayAccess.

offsetUnset

void offsetUnset($offset)

Implements ArrayAccess.

offsetGet

boolean offsetGet($offset)

Implements ArrayAccess

toArray

array toArray()

Returns the collection as an (associative) array.

keys

array keys()

Returns the keys.